summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2020-03-26 00:53:30 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2020-03-27 01:14:42 +0000
commit174aedcf7f3db9a7838de5891e95ab41f2373db4 (patch)
treec7a5c823ced9e8b6485d291e9610a5eec8693127
parentc4f18c29c794cf54fbab933082ac273cba795396 (diff)
downloadzsh-174aedcf7f3db9a7838de5891e95ab41f2373db4.tar.gz
zsh-174aedcf7f3db9a7838de5891e95ab41f2373db4.zip
45622: _quilt: Categorize subcommands
-rw-r--r--ChangeLog2
-rw-r--r--Completion/Unix/Command/_quilt41
2 files changed, 39 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b82f1a070..147344812 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2020-03-26 Daniel Shahaf <d.s@daniel.shahaf.name>
+ * 45622: Completion/Unix/Command/_quilt: Categorize subcommands
+
* 45584, 45620: Test/B12limit.ztst: zsh/rlimits: Skip the tests
for this module when it wasn't compiled in.
diff --git a/Completion/Unix/Command/_quilt b/Completion/Unix/Command/_quilt
index 76dda222f..d086da715 100644
--- a/Completion/Unix/Command/_quilt
+++ b/Completion/Unix/Command/_quilt
@@ -6,6 +6,8 @@ local verbose='(-h)-v[verbose, more user friendly output]'
local color='(-h)--color=[use syntax coloring]:color:(always auto never)'
local pstyle='(-h)-p+[select patch style]:patch style:((0\:exclude\ top-level\ directory 1\:use\ .orig\ on\ top-level\ directory ab\:use\ a\ or\ b\ as\ top-level\ directory))'
local -a pform rcfile
+local k
+
pform=(
'(-U -c -C -h)-u[create a unified diff]'
'(-u -c -C -h)-U+[create a unified diff with num lines of context]:lines'
@@ -36,12 +38,43 @@ _arguments $help \
'--trace[run the command in bash trace mode]' \
'--quiltrc=[use the specified configuration file]:files:_files' \
'--version[print the version number and exit]' \
- ':quilt command:(add annotate applied delete diff edit files fold fork graph
- grep header import mail new next patches pop previous push refresh remove
- rename revert series setup snapshot top unapplied upgrade)' \
+ ':quilt command:->cmd' \
'*:: :->subcmd' && return
-[[ -z $state ]] && return 1
+case $state in
+ ('')
+ return 1
+ ;;
+
+ (cmd)
+ # Divide the subcommands to categories. The categorization is our own;
+ # it's not based on any preexisting categorization in the quilt docs.
+ local -a manip=( add delete edit fold fork import new refresh remove rename )
+ local -a tree=( pop push revert )
+ local -a other=( grep header mail setup snapshot upgrade )
+ local -a interrogate=( annotate applied diff files graph next patches previous series top unapplied )
+ local -A cmdtypes=(
+ [manip]='series manipulator commands'
+ [tree]='tree manipulator commands'
+ [other]='other commands'
+ [interrogate]='series interrogator commands'
+ )
+ local -a expl=( )
+ local ret=1
+ _tags ${cmdtypes// /-}
+ while _tags; do
+ for k in ${(ok)cmdtypes}; do
+ _requested ${cmdtypes[$k]// /-} expl ${cmdtypes[$k]} \
+ compadd -a - $k && ret=0
+ done
+ done
+ return ret
+ ;;
+
+ (subcmd)
+ ;;
+esac
+
rcfile=( ${opt_args[--quiltrc]:+--quiltrc=${opt_args[--quiltrc]}} )
case $words[1] in
add)