From e1142935e508ac1f70ec3c074655124056dc7666 Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Fri, 14 Apr 2023 18:30:10 +0200 Subject: completion: zsh: allow args even when the command has subcommands This allows to show arguments on root level of commands that themselves have subcommands available. Complete those when any - is used in the completion word. --- contrib/completion/zsh/_devtools.in | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'contrib/completion') diff --git a/contrib/completion/zsh/_devtools.in b/contrib/completion/zsh/_devtools.in index e782fba..cc8d5cf 100644 --- a/contrib/completion/zsh/_devtools.in +++ b/contrib/completion/zsh/_devtools.in @@ -233,6 +233,10 @@ _pkgctl_cmds=( "repo[Manage Git packaging repositories and their configuration]" ) +_pkgctl_args=( + '(-h --help)'{-h,--help}'[Display usage]' +) + _pkgctl_diff_args=("${_diffpkg_args[@]}") _handle_subcommands() { @@ -243,8 +247,13 @@ _handle_subcommands() { '*::arg:->args' case $state in cmds) - local service_cmds=${service_name}_cmds[@] - _values "${(P)service_cmds}" + if [[ "${line[-1]}" == -* ]] && typeset -p ${service_name}_args &> /dev/null; then + local argname="${service_name}_args[@]" + _arguments -s "${(P)argname}" + else + local service_cmds=${service_name}_cmds[@] + _values "${(P)service_cmds}" + fi ;; args) local service_sub=${service_name}_$line[1] -- cgit v1.2.3-70-g09d2