From f604645d06d03a43de8c0c7192be0fda59c26758 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Fri, 24 Feb 2023 12:34:14 +0100 Subject: 51474: make -e and --vault-id options repeatable and update for new options to ansible 2.13.2 --- Completion/Unix/Command/_ansible | 89 +++++++++++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 25 deletions(-) (limited to 'Completion/Unix/Command/_ansible') diff --git a/Completion/Unix/Command/_ansible b/Completion/Unix/Command/_ansible index 2d976b0a0..7b85a58e4 100644 --- a/Completion/Unix/Command/_ansible +++ b/Completion/Unix/Command/_ansible @@ -20,8 +20,10 @@ case $service in ;| ansible|ansible-console|ansible-playbook|ansible-pull) args+=( - '(-K --ask-become-pass)'{-K,--ask-become-pass}'[ask for privilege escalation password]' - '(-k --ask-pass)'{-k,--ask-pass}'[ask for connection password]' + '(-K --ask-become-pass --become-password-file)'{-K,--ask-become-pass}'[ask for privilege escalation password]' + '(-K --ask-become-pass)--become-password-file=[specify file containing become password]:file:_files' + '(-k --ask-pass --connection-password-file)'{-k,--ask-pass}'[ask for connection password]' + '(-k --ask-pass)--connection-password-file=[specify file containing connection password]:file:_files' '--list-hosts[output list of matching hosts]' '(-l --limit)'{-l+,--limit=}'[further limit hosts to an additional pattern]:host subset:->hosts' '(-T --timeout)'{-T+,--timeout=}'[override the connection timeout]:timeout (seconds) [10]' @@ -49,8 +51,8 @@ case $service in ansible|ansible-console|ansible-inventory|ansible-playbook|ansible-pull) args+=( --ask-vault-pass{,word}'[ask for vault password]' - '(-e --extra-vars)'{-e+,--extra-vars=}'[set additional variables]:key=value or YAML/JSON' - '--vault-id=[specify vault identity to use]:vault identity' + \*{-e+,--extra-vars=}'[set additional variables]:key=value, YAML/JSON or @file:->extra-vars' + '*--vault-id=[specify vault identity to use]:vault identity' --vault-pass{,word}-file='[specify vault password file]:vault password file:_files' \*{-i+,--inventory=}'[specify inventory host file or host list]: : _alternative "files\:inventory file\:_files" "hosts\:host\: _sequence _hosts"' @@ -86,15 +88,15 @@ case $service in ) ;; ansible-config) - args+=( - '(-c --config)'{-c+,--config=}'[specify configuration file]:config file:_files' + args=( -A "-*" $args '1:action:(( list\:list\ all\ configuration dump\:show\ the\ current\ settings,\ merge\ specified\ configuration view\:display\ the\ current\ config\ file + init\:create\ initial\ configuration ))' + '*::args:->config' ) - [[ -n $words[(r)dump] ]] && args+=( '--only-changed[only show configuration that is changed from the default]' ) ;; ansible-console) args+=( @@ -103,11 +105,11 @@ case $service in ;; ansible-doc) args+=( - '!--metadata-dump' # "internal testing only" + '!--metadata-dump' '!--no-fail-on-errors' # "internal use only" '(-l --list -F --list_files -s --snippet --metadata-dump -e --entry-point)'{-j,--json}'[change output to json format]' '(-l --list -F --list_files -s --snippet --metadata-dump -e --entry-point)'{-l,--list}'[list available plugins]' '(-l --list -F --list_files -s --snippet --metadata-dump -e --entry-point)'{-F,--list_files}'[show plugin names and their source files without summaries]' - '(-l --list -F --list_files -s --snippet --metadata-dump -e --entry-point)'{-s,--snippet}'[show playbook snippet for specified plugins]' + '(-l --list -F --list_files -s --snippet --metadata-dump -e --entry-point)'{-s,--snippet}'[show playbook snippet for inventory, lookup and module plugins]' '(-l --list -F --list_files -s --snippet -e --entry-point)--metadata-dump[dump json metadata for all plugins]' '(-l --list -F --list_files -s --snippet --metadata-dump -e --entry-point)'{-e+,--entry-point=}'[select the entry point for roles]:entry point' '(-t --type)'{-t+,--type=}'[choose plugin type]:plugin type [module]:(become cache callback cliconf connection httpapi inventory lookup netconf shell vars module strategy role keyword)' @@ -218,18 +220,13 @@ case $state in ;; connect-types) plug=connection - ;& - plugins) - plugvar=_ansible_${plug}_plugins - typeset -ga ${plug} - if zstyle -T ":completion:${curcontext}:plugins" verbose; then - (( ${(P)#plugvar} )) || set -A ${plugvar} \ - ${${(f)"$(_call_program plugins ansible-doc -t $plug -l)"}/ ##/:} - _describe -t plugins "${plug} plugin" $plugvar -M 'r:|.=* r:|=*' && ret=0 + state=plugins + ;; + extra-vars) + if compset -P '@'; then + _files -g "*.(json|yml|yaml|ini)(-.)" && ret=0 else - (( ${(P)#plugvar} )) || set -A ${plugvar} \ - ${${(f)"$(_call_program plugins ansible-doc -t $plug -F)"}%% *} - _wanted plugins expl "${plug} plugin" compadd -M 'r:|.=* r:|=*' -a $plugvar && ret=0 + _message 'key=value, YAML/JSON or @file' fi ;; tags) @@ -237,9 +234,39 @@ case $state in _sequence _wanted tags expl tag compadd - \ ${(s.,.)${(j.,.)${(M)${(f)"$(cat **/*.yml)"}:# #tags:*}#*: }} && ret=0 ;; + config) + ign='' + curcontext="${curcontext%:*}-${words[1]}:" + (( $#words > 3 )) && ign='!' + args=( + "${ign}(-)"{-h,--help}'[display usage information]' + \*{-v,--verbose}'[verbose mode]' + '(-c --config)'{-c+,--config=}'[specify configuration file]:config file:_files' + '(-t --type)'{-t+,--type=}'[filter down to a specific plugin type]:plugin type [base]:(all base become cache callback cliconf connection httpapi inventory lookup netconf shell vars)' + '*:plugin:->plugins' + ) + case $words[1] in + dump) + args+=( + '(--only-changed --changed-only)'{--only-changed,--changed-only}'[only show configuration that is changed from the default]' + ) + ;; + init) + args+=( + '--format=[specify output format for init]:format:(init env vars)' + '--disabled[prefix all entries with a comment character]' + ) + ;; + esac + _arguments -s -S : $args && ret=0 + plug=${(v)opt_args[(i)-(t|-type)]} + [[ $plug = base ]] && state= + ;; galaxy) ign='' gactions=( delete import info init install list remove search setup ) + args=( "${ign}(-)"{-h,--help}'[display usage information]' ) + (( $#words > 3 )) && ign='!' case ${(j.:.)line[1,3]} in (role|collection):*:*) subcmd="${line[1]}-${line[2]}" @@ -253,14 +280,11 @@ case $state in [^:]#) words=( role "$words[@]" ) (( CURRENT++ )) + args=() ;; esac curcontext="${curcontext%:*}-${subcmd}:" - (( $#words > 3 )) && ign='!' - args=( - "${ign}(-)"{-h,--help}'[display usage information]' - '1: :{ _wanted actions expl action compadd -a gactions }' - ) + args+=( '1: :{ _wanted actions expl action compadd -a gactions }' ) case $subcmd in *-*) args+=( @@ -403,4 +427,19 @@ case $state in ;; esac +if [[ $state = plugins ]]; then + [[ -z $plug ]] && return ret + plugvar=_ansible_${plug}_plugins + typeset -ga ${plug} + if zstyle -T ":completion:${curcontext}:plugins" verbose; then + (( ${(P)#plugvar} )) || set -A ${plugvar} \ + ${${(f)"$(_call_program plugins ansible-doc -t $plug -l)"}/ ##/:} + _describe -t plugins "${plug} plugin" $plugvar -M 'r:|.=* r:|=*' && ret=0 + else + (( ${(P)#plugvar} )) || set -A ${plugvar} \ + ${${(f)"$(_call_program plugins ansible-doc -t $plug -F)"}%% *} + _wanted plugins expl "${plug} plugin" compadd -M 'r:|.=* r:|=*' -a $plugvar && ret=0 + fi +fi + return ret -- cgit v1.2.3 From c3cb5a3e0cd9b6e21d5e404649098c7c659c8f9a Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Tue, 14 Nov 2023 20:36:31 +0100 Subject: 52300: update completion options for ansible 2.15.2 --- ChangeLog | 4 ++++ Completion/Unix/Command/_ansible | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'Completion/Unix/Command/_ansible') diff --git a/ChangeLog b/ChangeLog index a3ce2e8d6..41eb95097 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2023-11-14 Oliver Kiddle + + * 52300: Completion/Unix/Command/_ansible: ansible 2.15.2 updates + 2023-11-09 Oliver Kiddle * 52280: Completion/Unix/Command/_git: update git completion for new diff --git a/Completion/Unix/Command/_ansible b/Completion/Unix/Command/_ansible index 7b85a58e4..bf31819ad 100644 --- a/Completion/Unix/Command/_ansible +++ b/Completion/Unix/Command/_ansible @@ -25,7 +25,6 @@ case $service in '(-k --ask-pass --connection-password-file)'{-k,--ask-pass}'[ask for connection password]' '(-k --ask-pass)--connection-password-file=[specify file containing connection password]:file:_files' '--list-hosts[output list of matching hosts]' - '(-l --limit)'{-l+,--limit=}'[further limit hosts to an additional pattern]:host subset:->hosts' '(-T --timeout)'{-T+,--timeout=}'[override the connection timeout]:timeout (seconds) [10]' '(-c --connection)'{-c+,--connection=}'[specify connection type]:connection type [smart]:->connect-types' '(-u --user)'{-u+,--user=}'[specify remote user for connection]:remote user:_users' @@ -44,7 +43,6 @@ case $service in '(-f --forks)'{-f+,--forks=}'[specify number of parallel processes to use]:processes [5]' '--become-method=[specify privilege escalation method to use]:method [sudo]:(sesu sudo su pbrun pfexec doas dzdo ksu runas pmrun enable machinectl)' '--become-user=[specify remote user for running operations]:user:_users' - "--syntax-check[perform a syntax check on the playbook, but don't execute it]" '!(-R --su-user -U --sudo-user)'{-R,-U,--su-user,--sudo-user}':user [root]:_users' ) ;| @@ -57,6 +55,7 @@ case $service in \*{-i+,--inventory=}'[specify inventory host file or host list]: : _alternative "files\:inventory file\:_files" "hosts\:host\: _sequence _hosts"' '!(-i --inventory)--inventory-file=:inventory file:_files' + '(-l --limit)'{-l+,--limit=}'[further limit hosts to an additional pattern]:host subset:->hosts' ) ;| ansible|ansible-console|ansible-inventory) @@ -112,7 +111,7 @@ case $service in '(-l --list -F --list_files -s --snippet --metadata-dump -e --entry-point)'{-s,--snippet}'[show playbook snippet for inventory, lookup and module plugins]' '(-l --list -F --list_files -s --snippet -e --entry-point)--metadata-dump[dump json metadata for all plugins]' '(-l --list -F --list_files -s --snippet --metadata-dump -e --entry-point)'{-e+,--entry-point=}'[select the entry point for roles]:entry point' - '(-t --type)'{-t+,--type=}'[choose plugin type]:plugin type [module]:(become cache callback cliconf connection httpapi inventory lookup netconf shell vars module strategy role keyword)' + '(-t --type)'{-t+,--type=}'[choose plugin type]:plugin type [module]:(become cache callback cliconf connection httpapi inventory lookup netconf shell vars module strategy test filter role keyword)' '(-r --roles-path)'{-r+,--roles-path=}'[specify directory containing roles]:directory:_directories' '*:plugin:->plugins' ) @@ -147,6 +146,7 @@ case $service in '--list-tags[list all available tags]' '--list-tasks[list all tasks that would be executed]' '--start-at-task=[start the playbook at specified task]:task' + "--syntax-check[perform a syntax check on the playbook, but don't execute it]" '--key-file=[specify file to use to authenticate the connection]:private key file:_files' '*:playbook:_files -g "(#i)*.y(|a)ml"' ) @@ -249,6 +249,7 @@ case $state in dump) args+=( '(--only-changed --changed-only)'{--only-changed,--changed-only}'[only show configuration that is changed from the default]' + '(-f --format)'{-f+,--format=}'[specify output format]:format:(json yaml display)' ) ;; init) @@ -257,6 +258,11 @@ case $state in '--disabled[prefix all entries with a comment character]' ) ;; + list) + args+=( + '(-f --format)'{-f+,--format=}'[specify output format]:format:(json yaml)' + ) + ;; esac _arguments -s -S : $args && ret=0 plug=${(v)opt_args[(i)-(t|-type)]} @@ -289,6 +295,7 @@ case $state in *-*) args+=( '(-c --ignore-certs)'{-c,--ignore-certs}'[ignore SSL certificate validation errors]' + '--timeout=[specify time to wait for operations against the galaxy]:timeout (seconds) [60]' '(-s --server)'{-s+,--server=}'[specify API server destination]:server:_hosts' --{token,api-key}='[specify ansible galaxy API key]:api key' \*{-v,--verbose}'[verbose mode]' -- cgit v1.2.3 From 1e995cbb384ddc931ba025a0f1cbc210d259f588 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Mon, 18 Mar 2024 21:12:55 +0100 Subject: 52769: fix completion of ansible keywords and --step option --- ChangeLog | 3 +++ Completion/Unix/Command/_ansible | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'Completion/Unix/Command/_ansible') diff --git a/ChangeLog b/ChangeLog index 290b1f1b2..3782b0d2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2024-03-18 Oliver Kiddle + * 52769: Completion/Unix/Command/_ansible: fix completion of + ansible keywords and --step option + * 52750: Config/defs.mk.in, Etc/zsh-development-guide, Src/Makemod.in.in, Src/Modules/files.c, Src/Modules/watch.c, Src/Modules/zftp.c, Src/Modules/zprof.c, Src/Zle/compcore.c, diff --git a/Completion/Unix/Command/_ansible b/Completion/Unix/Command/_ansible index bf31819ad..e0d9fb9b6 100644 --- a/Completion/Unix/Command/_ansible +++ b/Completion/Unix/Command/_ansible @@ -69,6 +69,11 @@ case $service in "--skip-tags[only run plays and tasks whose tags don't match]" ) ;| + ansible-playbook|ansible-console) + args+=( + '--step[one-step-at-a-time: confirm each task before running]' + ) + ;| ansible|ansible-console) args+=( '--task-timeout[set the task timeout limit]:timeout (seconds)' @@ -97,11 +102,6 @@ case $service in '*::args:->config' ) ;; - ansible-console) - args+=( - '--step[one-step-at-a-time: confirm each task before running]' - ) - ;; ansible-doc) args+=( '!--metadata-dump' '!--no-fail-on-errors' # "internal use only" @@ -440,11 +440,11 @@ if [[ $state = plugins ]]; then typeset -ga ${plug} if zstyle -T ":completion:${curcontext}:plugins" verbose; then (( ${(P)#plugvar} )) || set -A ${plugvar} \ - ${${(f)"$(_call_program plugins ansible-doc -t $plug -l)"}/ ##/:} + ${${${(f)"$(_call_program plugins ansible-doc -t $plug -l)"}:# *}/(:|) ##/:} _describe -t plugins "${plug} plugin" $plugvar -M 'r:|.=* r:|=*' && ret=0 else (( ${(P)#plugvar} )) || set -A ${plugvar} \ - ${${(f)"$(_call_program plugins ansible-doc -t $plug -F)"}%% *} + ${${(f)"$(_call_program plugins ansible-doc -t $plug -F)"}%%(|:) *} _wanted plugins expl "${plug} plugin" compadd -M 'r:|.=* r:|=*' -a $plugvar && ret=0 fi fi -- cgit v1.2.3