Improve ansible completion

Allow stacked/merged and repeated/incremental options
This commit is contained in:
Stefan Siegel 2018-06-12 01:17:23 +02:00
parent e0290834ac
commit 32875bed4b
3 changed files with 16 additions and 16 deletions

View File

@ -643,7 +643,7 @@ _ansible ()
local curcontext="$curcontext" state line local curcontext="$curcontext" state line
typeset -A opt_args typeset -A opt_args
_arguments -C -W \ _arguments -s -C -W \
'1:pattern:->pattern'\ '1:pattern:->pattern'\
"(-a --args)"{-a,--args}"[ARGS module arguments]:arguments:(ARG)"\ "(-a --args)"{-a,--args}"[ARGS module arguments]:arguments:(ARG)"\
'--ask-become-pass[ask for privilege escalation password]'\ '--ask-become-pass[ask for privilege escalation password]'\
@ -658,14 +658,14 @@ _ansible ()
"(-C --check)"{-C,--check}"[don't make any changes]"\ "(-C --check)"{-C,--check}"[don't make any changes]"\
"(-c --connection)"{-c,--connection}"[CONNECTION connection type to use (default=smart)]:connection type:(smart ssh local chroot)"\ "(-c --connection)"{-c,--connection}"[CONNECTION connection type to use (default=smart)]:connection type:(smart ssh local chroot)"\
"(-D --diff)"{-D,--diff}"[show differences when changing (small) files and templates]"\ "(-D --diff)"{-D,--diff}"[show differences when changing (small) files and templates]"\
"(-e --extra-vars)"{-e,--extra-vars}"[set additional variables as key=value or YAML/JSON]"\ "*"{-e,--extra-vars}"[set additional variables as key=value or YAML/JSON]"\
"(-f --forks)"{-f,--forks}"[FORKS number of parallel processes to use (default=5)]:forks:(5)"\ "(-f --forks)"{-f,--forks}"[FORKS number of parallel processes to use (default=5)]:forks:(5)"\
"(-h --help)"{-h,--help}"[help message]"\ "(-h --help)"{-h,--help}"[help message]"\
"(-i --inventory-file)"{-i,--inventory-file}"[INVENTORY specify inventory host file]:inventory file:_files"\ "*"{-i,--inventory,--inventory-file}"[INVENTORY specify inventory host file]:inventory file:_files"\
"(-l --limit)"{-l,--limit}"[SUBSET further limit selected hosts to an additional pattern]:subset pattern:->pattern"\ "(-l --limit)"{-l,--limit}"[SUBSET further limit selected hosts to an additional pattern]:subset pattern:->pattern"\
'--list-hosts[outputs a list of matching hosts. Does not execute anything else]'\ '--list-hosts[outputs a list of matching hosts. Does not execute anything else]'\
"(-m --module-name)"{-m,--module-name}"[MODULE_NAME module name (default=command)]:module name:->module"\ "(-m --module-name)"{-m,--module-name}"[MODULE_NAME module name (default=command)]:module name:->module"\
"(-M --module-path)"{-M,--module-path}"[MODULE_PATH specify path to module library (default=None)]:module path:_files -/"\ "*"{-M,--module-path}"[MODULE_PATH specify path to module library (default=None)]:module path:_files -/"\
'--new-vault-password-file[new vault password file for rekey]:new vault password file:_files'\ '--new-vault-password-file[new vault password file for rekey]:new vault password file:_files'\
"(-o --one-line)"{-o,--one-line}"[condense output]"\ "(-o --one-line)"{-o,--one-line}"[condense output]"\
'--output[output file name for encrypt or decrypt; use - for stdout]:output file:_files'\ '--output[output file name for encrypt or decrypt; use - for stdout]:output file:_files'\
@ -683,8 +683,8 @@ _ansible ()
"(-T --timeout)"{-T,--timeout}"[TIMEOUT override the SSH timeout (s) (default=10)]:ssh timeout:(10)"\ "(-T --timeout)"{-T,--timeout}"[TIMEOUT override the SSH timeout (s) (default=10)]:ssh timeout:(10)"\
"(-t --tree)"{-t,--tree}"[OUTPUT_DIRECTORY log output to this directory]:output directory:_files -/"\ "(-t --tree)"{-t,--tree}"[OUTPUT_DIRECTORY log output to this directory]:output directory:_files -/"\
"(-u --user)"{-u,--user}"[REMOTE_USER connect as this user (default=${USER})]:connect as user:(${USER})"\ "(-u --user)"{-u,--user}"[REMOTE_USER connect as this user (default=${USER})]:connect as user:(${USER})"\
"--vault-password-file[VAULT_PASSWORD_FILE vault password file]:vault password file:_files"\ "*--vault-password-file[VAULT_PASSWORD_FILE vault password file]:vault password file:_files"\
"(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]"\ "*"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]"\
"--version[show program's version number and exit]"\ "--version[show program's version number and exit]"\
case $state in case $state in

View File

@ -84,7 +84,7 @@ _ansible-galaxy ()
_arguments \ _arguments \
"(-h --help)"{-h,--help}"[help message]" \ "(-h --help)"{-h,--help}"[help message]" \
"(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \ "(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \
"(-p --roles-path)"{-p,--roles-path}"[ROLES_PATH The path to the directory containing your roles (default: from ansible.cfg)]:roles path:_files -/" \ "*"{-p,--roles-path}"[ROLES_PATH The path to the directory containing your roles (default: from ansible.cfg)]:roles path:_files -/" \
"(-s --server)"{-s,--server}"[API_SERVER The API server destination]:api server:(http://apiserver)" \ "(-s --server)"{-s,--server}"[API_SERVER The API server destination]:api server:(http://apiserver)" \
"(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \ "(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \
"--version[show program's version number and exit]" \ "--version[show program's version number and exit]" \

View File

@ -126,8 +126,8 @@ _ansible-playbook ()
local curcontext="$curcontext" state line local curcontext="$curcontext" state line
typeset -A opt_args typeset -A opt_args
_arguments -C -W \ _arguments -s -C -W \
"1:playbook yml file:_files -g '*.yml|*.yaml'"\ "*:playbook yml file:_files -g '*.yml|*.yaml'"\
'--ask-become-pass[ask for privilege escalation password]'\ '--ask-become-pass[ask for privilege escalation password]'\
"(-k --ask-pass)"{-k,--ask-pass}"[ask for connection password]"\ "(-k --ask-pass)"{-k,--ask-pass}"[ask for connection password]"\
'--ask-su-pass[ask for su password (deprecated, use become)]'\ '--ask-su-pass[ask for su password (deprecated, use become)]'\
@ -139,23 +139,23 @@ _ansible-playbook ()
"(-C --check)"{-C,--check}"[don't make any changes]"\ "(-C --check)"{-C,--check}"[don't make any changes]"\
"(-c --connection)"{-c,--connection}"[CONNECTION connection type to use (default=smart)]:connection type:(smart ssh local chroot)"\ "(-c --connection)"{-c,--connection}"[CONNECTION connection type to use (default=smart)]:connection type:(smart ssh local chroot)"\
"(-D --diff)"{-D,--diff}"[when changing (small files and templates, show the diff in those. Works great with --check)]"\ "(-D --diff)"{-D,--diff}"[when changing (small files and templates, show the diff in those. Works great with --check)]"\
"(-e --extra-vars)"{-e,--extra-vars}"[EXTRA_VARS set additional variables as key=value or YAML/JSON]:extra vars:(EXTRA_VARS)"\ "*"{-e,--extra-vars}"[EXTRA_VARS set additional variables as key=value or YAML/JSON]:extra vars:(EXTRA_VARS)"\
'--flush-cache[clear the fact cache]'\ '--flush-cache[clear the fact cache]'\
'--force-handlers[run handlers even if a task fails]'\ '--force-handlers[run handlers even if a task fails]'\
"(-f --forks)"{-f,--forks}"[FORKS number of parallel processes to use (default=5)]:forks:(5)"\ "(-f --forks)"{-f,--forks}"[FORKS number of parallel processes to use (default=5)]:forks:(5)"\
"(-h --help)"{-h,--help}"[help message]"\ "(-h --help)"{-h,--help}"[help message]"\
"(-i --inventory-file)"{-i,--inventory-file}"[INVENTORY specify inventory host file]:inventory file:_files"\ "*"{-i,--inventory,--inventory-file}"[INVENTORY specify inventory host file]:inventory file:_files"\
"(-l --limit)"{-l,--limit}"[SUBSET further limit selected hosts to an additional pattern]:subset pattern:->pattern"\ "(-l --limit)"{-l,--limit}"[SUBSET further limit selected hosts to an additional pattern]:subset pattern:->pattern"\
'--list-hosts[outputs a list of matching hosts. Does not execute anything else]'\ '--list-hosts[outputs a list of matching hosts. Does not execute anything else]'\
'--list-tags[list all available tags]'\ '--list-tags[list all available tags]'\
'--list-tasks[list all tasks that would be executed]'\ '--list-tasks[list all tasks that would be executed]'\
"(-M --module-path)"{-M,--module-path}"[MODULE_PATH specify path to module library (default=None)]:module path:_files -/"\ "*"{-M,--module-path}"[MODULE_PATH specify path to module library (default=None)]:module path:_files -/"\
'--new-vault-password-file[new vault password file for rekey]:new vault password file:_files'\ '--new-vault-password-file[new vault password file for rekey]:new vault password file:_files'\
'--output[output file name for encrypt or decrypt; use - for stdout]:output file:_files'\ '--output[output file name for encrypt or decrypt; use - for stdout]:output file:_files'\
'--private-key[PRIVATE_KEY_FILE use this file to authenticate the connection]:private key file:_files'\ '--private-key[PRIVATE_KEY_FILE use this file to authenticate the connection]:private key file:_files'\
'--scp-extra-args[specify extra arguments to pass to scp only]'\ '--scp-extra-args[specify extra arguments to pass to scp only]'\
'--sftp-extra-args[specify extra arguments to pass to sftp only]'\ '--sftp-extra-args[specify extra arguments to pass to sftp only]'\
"--skip-tags[SKIP_TAGS only run plays and tasks whose tags do not match these values]:skip tags:(SKIP_TAGS)"\ "*--skip-tags[SKIP_TAGS only run plays and tasks whose tags do not match these values]:skip tags:(SKIP_TAGS)"\
'--ssh-common-args[specify common arguments to pass to sftp/scp/ssh]'\ '--ssh-common-args[specify common arguments to pass to sftp/scp/ssh]'\
'--ssh-extra-args[specify extra arguments to pass to ssh only]'\ '--ssh-extra-args[specify extra arguments to pass to ssh only]'\
"--start-at-task[START_AT start the playbook at the task matching this name]:name:(TASK_NAME)"\ "--start-at-task[START_AT start the playbook at the task matching this name]:name:(TASK_NAME)"\
@ -165,11 +165,11 @@ _ansible-playbook ()
"(-s --sudo)"{-s,--sudo}"[run operations with sudo (nopasswd) (deprecated, use become)]"\ "(-s --sudo)"{-s,--sudo}"[run operations with sudo (nopasswd) (deprecated, use become)]"\
"(-U --sudo-user)"{-U,--sudo-user}"[SUDO_USER desired sudo user (default=root) (deprecated, use become)]:su user:(root)"\ "(-U --sudo-user)"{-U,--sudo-user}"[SUDO_USER desired sudo user (default=root) (deprecated, use become)]:su user:(root)"\
'--syntax-check[perform a syntax check on the playbook, but do not execute it]'\ '--syntax-check[perform a syntax check on the playbook, but do not execute it]'\
"(-t --tags)"{-t,--tags}"[TAGS only run plays and tasks gagged with these values]:task tags:(TAGS)"\ "*"{-t,--tags}"[TAGS only run plays and tasks gagged with these values]:task tags:(TAGS)"\
"(-T --timeout)"{-T,--timeout}"[TIMEOUT override the SSH timeout (s) (default=10)]:ssh timeout:(10)"\ "(-T --timeout)"{-T,--timeout}"[TIMEOUT override the SSH timeout (s) (default=10)]:ssh timeout:(10)"\
"(-u --user)"{-u,--user}"[REMOTE_USER connect as this user (default=${USER})]:connect as user:(${USER})"\ "(-u --user)"{-u,--user}"[REMOTE_USER connect as this user (default=${USER})]:connect as user:(${USER})"\
"--vault-password-file[VAULT_PASSWORD_FILE vault password file]:vault password file:_files"\ "*--vault-password-file[VAULT_PASSWORD_FILE vault password file]:vault password file:_files"\
"(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]"\ "*"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]"\
"--version[show program's version number and exit]"\ "--version[show program's version number and exit]"\
case $state in case $state in