summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordana <dana@dana.is>2019-02-22 13:14:16 -0600
committerdana <dana@dana.is>2019-02-22 13:14:16 -0600
commit7930905f0ccddd8899a73cfe77f04a9646a6a6be (patch)
tree0d46807e43afbeb4f08bb01364fe02bf93e09d2a
parent0afe9dc02a941be1f910b89af7e5f6d342503978 (diff)
downloadzsh-7930905f0ccddd8899a73cfe77f04a9646a6a6be.tar.gz
zsh-7930905f0ccddd8899a73cfe77f04a9646a6a6be.zip
44076: _column: Support Debian, add missing options, adjust wording
Tweaked per off-list discussion with Daniel: We agreed that it would be best to side-step the wording disagreement between the BSD and util-linux implementations by using our own description for -x, which was borrowed from the one for `print -ca`
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Command/_column46
2 files changed, 39 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index a1afc5115..a9fc99232 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-02-22 dana <dana@dana.is>
+
+ * 44076 (tweaked): Completion/Unix/Command/_column: Support
+ Debian column, add missing util-linux options, adjust wording
+
2019-02-18 Peter Stephenson <p.stephenson@samsung.com>
* Yutian Li: 44067: Src/hist.c: If history read was interrupted,
diff --git a/Completion/Unix/Command/_column b/Completion/Unix/Command/_column
index a81684dba..94bdccf0a 100644
--- a/Completion/Unix/Command/_column
+++ b/Completion/Unix/Command/_column
@@ -1,33 +1,48 @@
#compdef column
-local ret=1
-local -a context state line expl args columns MATCH
+# Note: BSD and util-linux disagree on how to describe the behaviour of the -x
+# option. We use our own wording to avoid confusion
+
+local variant ret=1
+local -a context state line expl args columns MATCH aopts=( -A '-*' )
local -i MBEGIN MEND
local -A opt_args
-case $OSTYPE in
- linux-gnu)
+# Debian and its derivatives (as of 2019) ship with a slightly customised
+# version of the BSD column instead of the util-linux one. It can be identified
+# by the presence of the custom option -n in the synopsis
+_pick_variant -r variant \
+ util-linux='(#i)util-linux' \
+ debian='\[-[A-Za-z]#n[A-Za-z]#\]' \
+ $OSTYPE \
+--version
+
+case $variant in
+ util-linux)
+ aopts=()
args=(
'(info json -c --output-width)'{-c+,--output-width=}'[format output to fit display of specified width]:width'
'(info)'{-L,--table-empty-lines}"[don't ignore empty lines]"
+ fill
- '(info table text json -x --fillrows)'{-x,--fillrows}'[fill rows before filling columns]'
+ '(info table text json -x --fillrows)'{-x,--fillrows}'[print across before down]'
+ table
'(info fill -t --table)'{-t,--table}'[create a table]'
+ '(info fill -o --output-separator)'{-o+,--output-separator=}'[specify column separator for table output]:separator [two spaces]'
'(info fill -s --separator)'{-s+,--separator=}'[specify column delimiters in input data]:delimiters'
'(info fill -O --table-order)'{-O+,--table-order=}'[specify order of output columns]: :->columns'
'(info fill -N --table-columns)'{-N+,--table-columns=}'[specify column names]:names'
'(info fill -H --table-hide)'{-H+,--table-hide=}"[don't print specified columns]: :->columns"
+ text
'(info fill json -d --table-noheadings)'{-d,--table-noheadings}"[don't print header]"
- '(info fill json -E --table-noextreme)'{-E,--table-noextreme}"[specify columns where length can be ignored]: :->columns"
+ '(info fill json -E --table-noextreme)'{-E+,--table-noextreme}"[specify columns where length can be ignored]: :->columns"
'(info fill json -e --table-header-repeat)'{-e,--table-header-repeat}'[repeat header for each page]'
+ '(info fill json -H --table-hide)'{-H+,--table-hide=}"[don't print specified columns]: :->columns"
'(info fill json -R --table-right)'{-R+,--table-right=}'[right align text in these columns]: :->columns'
'(info fill json -T --table-truncate)'{-T+,--table-truncate=}'[truncate text in the columns when necessary]: :->columns'
'(info fill json -W --table-wrap)'{-W+,--table-wrap=}'[wrap text in the columns when necessary]: :->columns'
- '(info fill json -r --tree)'{-r+,--tree=}'[specify column to format tree-like]: :->column'
- '(info fill json -i --tree-id)'{-i+,--tree-id=}'[specify column containing ID for child-parent relations]: :->column'
- '(info fill json -p --tree-parent)'{-p+,--tree-parent=}'[specify column containing reference to parent]: :->column'
+ '(info fill json -r --tree)'{-r+,--tree=}'[specify column to format tree-like]: :->columns'
+ '(info fill json -i --tree-id)'{-i+,--tree-id=}'[specify column containing ID for child-parent relations]: :->columns'
+ '(info fill json -p --tree-parent)'{-p+,--tree-parent=}'[specify column containing reference to parent]: :->columns'
+ json
'(info fill text -n --table-name -c --output-width)'{-n+,--table-name=}'[specify table name for JSON output]:name'
'(info fill text -J --json -c --output-width)'{-J,--json}'[use JSON output format for table]'
@@ -36,17 +51,24 @@ case $OSTYPE in
'(- *)'{-V,--version}'[display version information]'
)
;;
- *)
+ debian)
+ aopts=()
args=(
+ "(-x)-n[don't merge multiple adjacent delimiters]"
+ "-e[don't ignore empty lines]"
+ )
+ ;& # FALL THROUGH
+ *)
+ args+=(
'(-t -s)-c+[format output to fit display of specified width]:width'
'(-c -x)-t[create a table]'
'(-c -x)-s+[specify column delimiters in input data]:delimiters'
- '(-t -s)-x[fill rows before filling columns]'
+ '(-n -t -s)-x[print across before down]'
)
;;
esac
-_arguments -s -S '*:file:_files' $args && ret=0
+_arguments -s -S $aopts '*:file:_files' $args && ret=0
if [[ -n $state ]]; then
columns=( ${(s.,.)${(Q)${opt_args[table--N]:-$opt_args[table---table-columns]}//(#m)\\([\\:])/${MATCH[2]}}} )