从stdin读取输入并将其转换为jira表的工具
toJiraTable的Python项目详细描述
从stdin读取输入并将其转换为jira表。
它读取的第一行用作表头,随后的所有行都生成到正文中。支持shell样式的字段拆分(可以使用引号将带有空格的项“分组”到单个字段中)。
默认情况下,它将被空格分隔,因此每个单词都成为一个项。默认情况下,整个表将增长到最长的行,并在需要时填充空白。
如果需要按其他方式拆分,例如两个空格(如果列由两个或多个空格分隔,并且包含空格之间的字符),则有多种可用的–按选项拆分,请参阅下面的用法。有关详细信息,请参见用法和示例。
用法:
Usage: toJiraTable
Converts stdin to a JIRA table. If no arguments provided, it will use “shell-style” splitting
so quoting strings with spaces makes them a single column, otherwise spaces/tabs/whatever
splits. The first line passed in becomes the header, the remainder become the body.
默认情况下,所有内容都将匹配到最长的行。行中任何缺少的列都将
be filled by blank columns at the end. Use –no-stretch to disable this.
Arguments:
–no-stretch - Do not stretch each row to the longest row. See above.
–split-header-by=X - Instead of using shell-style splitting, split by provided string for the header line
–split-body-by=X - Instead of using shell-style splitting, split by the provided string for body lines
–split-by=X - Split both header and body by the given string
–split-keep-empty - By default, using the –split-by* will strip empty columns. The default behaviour is
useful, in example: if a script outputs strings which are not quoted, but has at least two
spaces between each real column, using –split-body-by=’ ‘ will ensure that any place that
is separated by two or more spaces becomes a column. This option disables that feature.
示例用法:
简单拆分:
[myuser]$ ( echo ‘Hostname “Free Space”’; cat hostnames.txt ) | toJiraTable
||Hostname||Free Space||
|host1|500G|
|wwwprod1|120G|
|wwwdev1|11G|
更复杂的拆分。在这种情况下,我们希望主体在至少有两个空格时形成列:
(数据集)
[myuser]$ cat myData
Name Size Comment
George Jetson 500G The man from the future
Jeeves 200M Everyone’s favourite butlet
(转换为JIRA表格)
[myuser]$ cat myData | ./toJiraTable –split-body-by=” “
||Name||Size||Comment||
|George Jetson|500G|The man from the future|
|Jeeves|200M|Everyone’s favourite butlet|
制表符取消拆分:
(数据集):
[myuser]$ python -c “import sys; sys.stdout.write(repr(open(‘myData’, ‘rt’).read()).replace(‘\n’, ‘\n’) + ‘n’);”
“NametSizetComment
George Jetsont500GtThe man from the future
Jeevest200MtEveryone’s favourite butlet
“
(转换为JIRA表格)
[myuser]$ cat myData | ./toJiraTable –split-by=’t’
||Name||Size||Comment||
|George Jetson|500G|The man from the future|
|Jeeves|200M|Everyone’s favourite butlet|