_ansible in zsh replaces all our _ansible* compdefs

This commit is contained in:
Julien Nicoulaud 2018-11-04 14:41:31 +01:00
parent 9edc47d5a3
commit f8cede57f0
No known key found for this signature in database
GPG Key ID: D713C40AA20BF77D
3 changed files with 0 additions and 468 deletions

View File

@ -1,183 +0,0 @@
#compdef ansible-galaxy
# ------------------------------------------------------------------------------
# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the zsh-users nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for ansible-galaxy v2.0.0.2 (http://ansible.org)
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Romain Bossart (https://github.com/bosr)
# * Adam Stevko (https://github.com/xen0l)
#
# ------------------------------------------------------------------------------
#
# Note: I tried to use `_arguments --`, but the output of `ansible --help`
# is not parsed entirely correctly, and anyway no modules or host would available.
#
# ansible-galaxy zsh completion
#
_ansible-galaxy ()
{
local context curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
"1:command:(delete import info init install list login remove search setup)" \
"*::option:->option"
case $state in
option)
case $line[1] in
delete)
_arguments \
"(-h --help)"{-h,--help}"[help message]" \
"(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \
"(-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)]" \
"--version[show program's version number and exit]" \
":github_user:(GITHUB_USER)" \
":github_repo:(GITHUB_REPO)"
;;
import)
_arguments \
"--branch[REFERENCE The name of a branch to import.]:reference:(master)" \
"(-h --help)"{-h,--help}"[help message]" \
"(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \
"--no-wait[Don't wait for import results.]" \
"(-s --server)"{-s,--server}"[API_SERVER The API server destination]:api server:(http://apiserver)" \
"--status[Check the status of the most recent import request forgiven github_user/github_repo.]" \
"(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \
"--version[show program's version number and exit]" \
":github_user:(GITHUB_USER)" \
":github_repo:(GITHUB_REPO)"
;;
info)
_arguments \
"(-h --help)"{-h,--help}"[help message]" \
"(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \
"*"{-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)" \
"(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \
"--version[show program's version number and exit]" \
":role name:(ROLE,version)"
;;
init)
_arguments \
"(-f --force)"{-f,--force}"[ Force overwriting an existing role]" \
"(-h --help)"{-h,--help}"[help message]" \
"(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \
"(-p --init-path)"{-p,--init-path}"[INIT_PATH path in which the skeleton role will be created (default=./)]:init path:(./)" \
"(--offline)--offline[Don't query the galaxy API when creating roles]" \
"(-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)]" \
"--version[show program's version number and exit]" \
":role name:(ROLE)"
;;
install)
_arguments \
"(-f --force)"{-f,--force}"[Force overwriting an existing role]" \
"(-h --help)"{-h,--help}"[help message]" \
"(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \
"(-i --ignore-errors)"{-i,--ignore-errors}"[Ignore errors and continue with the next specified role]" \
"(-n --no-deps)"{-n,--no-deps}"[Don't download roles listed as dependencies]" \
"(-r --role-file)"{-r,--role-file}"[ROLE_FILE A file containing a list of roles to be imported]:role file:_files" \
"(-p --roles-path)"{-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)" \
"(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \
"--version[show program's version number and exit]" \
":role name:(ROLE)"
;;
list)
_arguments \
"(-h --help)"{-h,--help}"[help message]" \
"(-p --roles-path)"{-p,--roles-path}"[ROLES_PATH The path to the directory containing your roles (default: from ansible.cfg)]:roles path:_files -/" \
"(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \
"--version[show program's version number and exit]" \
":role name:(ROLE)"
;;
login)
_arguments \
"--github_token[TOKEN Identify with github token rather than username and password.]:token:(TOKEN)" \
"(-h --help)"{-h,--help}"[help message]" \
"(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \
"(-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)]" \
"--version[show program's version number and exit]"
;;
remove)
_arguments \
"(-h --help)"{-h,--help}"[help message]" \
"(-p --roles-path)"{-p,--roles-path}"[ROLES_PATH The path to the directory containing your roles (default: from ansible.cfg)]:roles path:_files -/" \
"(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \
"--version[show program's version number and exit]" \
"*:role name:(ROLE)"
;;
search)
_arguments \
"--author[AUTHOR GitHub username]:author:(AUTHOR)" \
"--galaxy-tags[TAGS list of galaxy tags to filter by]:tags:(TAGS)" \
"(-h --help)"{-h,--help}"[help message]" \
"(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \
"--platforms[PLATFORMS list of OS platforms to filter by" \
"(-p --roles-path)"{-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)" \
"(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \
"--version[show program's version number and exit]"
;;
setup)
_arguments \
"(-h --help)"{-h,--help}"[help message]" \
"(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \
"--list[List all of your integrations.]" \
"--remove[REMOVE_ID Remove the integration matching the provided ID value.]:id:(REMOVE_ID)" \
"(-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)]" \
"--version[show program's version number and exit]" \
":source:(travis)" \
":github_user:(GITHUB_USER)" \
":github_repo:(GITHUB_REPO)" \
":secret:(SECRET)"
;;
esac
;;
esac
}
_ansible-galaxy "$@"
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et

View File

@ -1,191 +0,0 @@
#compdef ansible-playbook
# ------------------------------------------------------------------------------
# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the zsh-users nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for ansible-playbook v2.0.0.2 (http://ansible.org)
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Romain Bossart (https://github.com/bosr)
# * Adam Stevko (https://github.com/xen0l)
#
# ------------------------------------------------------------------------------
#
# Needs either ANSIBLE_HOSTS or /etc/ansible/hosts on linux
# (or /usr/local/etc/ansible/hosts on macOS)
#
# Note 1: the following gist (https://gist.github.com/15ed54a438a36d67fd99.git)
# has some files to help improve the hostfile shell parsing
#
# Note 2: I tried to use `_arguments --`, but the output of `ansible --help`
# is not parsed entirely correctly, and anyway no modules or host would available.
#
# ansible-playbook zsh completion
#
__host_file_location () {
# find the location of the host file:
# 1. check $ANSIBLE_HOSTS
# 2. else check /etc/ansible/hosts or /usr/local/etc/...
# (depending on platform)
#
[[ "$OSTYPE" == darwin* ]] && FALLBACK="/usr/local/etc/ansible/hosts"
[[ "$OSTYPE" == linux* ]] && FALLBACK="/etc/ansible/hosts"
HOST_FILE=${ANSIBLE_HOSTS:=${FALLBACK}}
[[ -f ${HOST_FILE} ]] || HOST_FILE="$PWD/ansible/inventory/hosts"
[[ -f ${HOST_FILE} ]] || HOST_FILE=/dev/null
echo ${HOST_FILE}
}
__ll_group_list () {
# parses the ini hostfile for groups only: [...]
HOST_FILE=$(__host_file_location)
local -a group_list
group_list=$(command \
cat ${HOST_FILE} \
| awk '$1 ~ /^\[.*\]$/ && !/=/ && !/:vars/ \
{ gsub(/[\[\]]/, "", $1); gsub(/:children/, "", $1) ; print $1 }' \
| uniq )
echo ${group_list}
}
__host_list ()
{
# parses the ini hostfile for hosts only
# but then has to remove all group occurrences
HOST_FILE=$(__host_file_location)
# this will also contain groups if they are referenced in other groups
local -a mixed_host_list
mixed_host_list=$(command \
cat ${HOST_FILE} \
| awk 'NF && $1 !~ /[\[:=]/ { print $1 }' \
| sort | uniq)
# compute set difference h1 - h2
local -a h1 h2 host_list
h1=${mixed_host_list}
h2=$(__ll_group_list)
host_list=($(command \
sort <(echo $h1) <(echo $h2) <(echo $h2) \
| uniq -u \
| paste -s -d ' ' - )
)
_wanted application expl 'hosts' compadd ${host_list}
# method that delegates to ansible (slow)
# _wanted application expl 'hosts' compadd $(command ansible \
# all --list-hosts\
# 2>/dev/null)
}
__group_list ()
{
gl=($(command echo $(__ll_group_list) | paste -s -d ' ' - )) # 'a\nb\nc' -> (a b c)
_wanted application2 expl 'groups' compadd $gl
}
_ansible-playbook ()
{
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -s -C -W \
"*:playbook yml file:_files -g '*.yml|*.yaml'"\
'--ask-become-pass[ask for privilege escalation password]'\
"(-k --ask-pass)"{-k,--ask-pass}"[ask for connection password]"\
'--ask-su-pass[ask for su password (deprecated, use become)]'\
"(-K --ask-sudo-pass)"{-K,--ask-sudo-pass}"[ask for sudo password (deprecated, use become)]"\
'--ask-vault-pass[ask for vault password]'\
"(-b --become)"{-b,--become}"[run operations with become (nopasswd implied)]"\
'--become-method[privilege escalation method to use (default=sudo)]:method:(sudo su pbrun pfexec runas doas)'\
'--become-user[run operations as this user (default=root)]:user:(USER)'\
"(-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)"\
"(-D --diff)"{-D,--diff}"[when changing (small files and templates, show the diff in those. Works great with --check)]"\
"*"{-e,--extra-vars}"[EXTRA_VARS set additional variables as key=value or YAML/JSON]:extra vars:(EXTRA_VARS)"\
'--flush-cache[clear the fact cache]'\
'--force-handlers[run handlers even if a task fails]'\
"(-f --forks)"{-f,--forks}"[FORKS number of parallel processes to use (default=5)]:forks:(5)"\
"(-h --help)"{-h,--help}"[help message]"\
"*"{-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"\
'--list-hosts[outputs a list of matching hosts. Does not execute anything else]'\
'--list-tags[list all available tags]'\
'--list-tasks[list all tasks that would be executed]'\
"*"{-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'\
'--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'\
'--scp-extra-args[specify extra arguments to pass to scp 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)"\
'--ssh-common-args[specify common arguments to pass to sftp/scp/ssh]'\
'--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)"\
'--step[one-step-at-a-time: confirm each task before running]'\
"(-S --su)"{-S,--su}"[run operations with su (deprecated, use become)]"\
"(-R --su-user)"{-R,--su-user}"[SU_USER run operations with su as this user (default=root) (deprecated, use become)]:su user:(root)"\
"(-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)"\
'--syntax-check[perform a syntax check on the playbook, but do not execute it]'\
"*"{-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)"\
"(-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"\
"*"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]"\
"--version[show program's version number and exit]"\
case $state in
pattern)
_arguments '*:feature:__host_list'
_arguments '*:feature:__group_list'
;;
esac
}
_ansible-playbook "$@"
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et

View File

@ -1,94 +0,0 @@
#compdef ansible-vault
# ------------------------------------------------------------------------------
# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the zsh-users nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for ansible v1.9.2 (http://ansible.org)
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Rick van Hattem (https://github.com/wolph)
#
# ------------------------------------------------------------------------------
#
_ansible-vault-commands() {
local -a commands
commands=(
'create:Create new encrypted file'
'decrypt:Decrypt encrypted file'
'edit:Edit encrypted file'
'encrypt:Encrypt unencrypted file'
'rekey:Change password for encrypted file'
'view:View encrypted file'
)
_arguments -s : $nul_args && ret=0
_describe -t commands 'ansible-vault command' commands && ret=0
}
_ansible-vault-command(){
args=(
'--debug[enable debugging]' \
'--vault-password-file[vault password file]:password_file:_files'
$nul_args
"1::file_name:_files"
)
_arguments -s : $args && ret=0
}
_ansible-vault() {
local -a nul_args
nul_args=(
'(-h --help)'{-h,--help}'[show help message and exit.]'
)
local curcontext=$curcontext ret=1
if ((CURRENT == 2)); then
_ansible-vault-commands
else
shift words
(( CURRENT -- ))
curcontext="${curcontext%:*:*}:ansible-vault-$words[1]:"
_call_function ret _ansible-vault-command
fi
}
_ansible-vault "$@"
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et