You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcpcfg/debian/ngcpcfg.completion

151 lines
4.5 KiB

# ngcpcfg(8) completion -*- shell-script -*-
_ngcpcfg()
{
local cur prev words cword
_init_completion || return
case $prev in
apply)
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--force-all-services' -- "$cur" ) )
fi
return
;;
build)
cur=${cur:-/etc/}
_filedir
return
;;
check)
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--ignore-branch-check --ignore-shared-storage-check' -- "$cur" ) )
else
[[ -n "$cur" ]] && _filedir yml && return 0
COMPREPLY=( $( compgen -G "/etc/ngcp-config/*.yml" -- "$cur" ) ) || _filedir yml
compopt -o nospace
fi
return
;;
clean)
if [[ "$cur" == -* ]]; then
local -a opts=(
--all
--branches
--force
--help
--reset-master
--stashes
--tracked-files
--untracked-files
)
COMPREPLY=( $( compgen -W '${opts[@]}' -- "$cur" ) )
else
_filedir
compopt +o nospace
fi
return
;;
commit)
return
;;
del)
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--diff' -- "$cur" ) )
fi
_filedir
compopt +o nospace
return
;;
diff)
if [[ "$cur" == -* ]]; then
if [ -r /usr/share/bash-completion/completions/git ] ; then
unset __git_diff_common_options
. /usr/share/bash-completion/completions/git
COMPREPLY=( $( compgen -W "$__git_diff_common_options" -- "$cur" ) )
fi
else
[[ -n "$cur" ]] && _filedir yml && return 0
compopt -o nospace
fi
return
;;
get)
# XXX - would be nice to get completion based on content of /etc/ngcp-config/*.yml
return
;;
help)
return
;;
log)
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-p' -- "$cur" ) )
fi
return
;;
patch)
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --from-customtt' -- "$cur" ) )
else
_filedir
compopt +o nospace
fi
return
;;
pull)
return
;;
push|push-parallel)
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--nobuild --noapply --shared-only' -- "$cur" ) )
else
_known_hosts_real -- "$cur"
fi
return
;;
services)
return
;;
set)
[[ -n "$cur" ]] && _filedir yml && return 0
COMPREPLY=( $( compgen -G "/etc/ngcp-config/*.yml" -- "$cur" ) ) || _filedir yml
compopt -o nospace
return 0
;;
show)
COMPREPLY=( $( compgen -W "$(cd /etc/ngcp-config && git rev-list master --abbrev-commit 2>/dev/null)" -- "$cur" ) )
return
;;
status)
COMPREPLY=( $( compgen -W '--local-only' -- "$cur" ) )
return
;;
version)
return
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--debug --validate --version' -- "$cur" ) )
else
if [[ $cword -eq 1 ]]; then
local -a scripts=( help version ) # those options don't have separate ngcpcfg scripts
for f in /usr/share/ngcp-ngcpcfg/scripts/* ; do
case "$(basename "$f")" in
decrypt|encrypt|etckeeper|initialise|init-mgmt|init-shared) # not relevant for common operations
;;
values) # deprecated options
;;
*)
scripts+=( $(basename "$f") )
;;
esac
done
COMPREPLY=( $( compgen -W '${scripts[@]}' -- "$cur" ) )
fi
fi
} &&
complete -F _ngcpcfg ngcpcfg ngcp-config
# ex: filetype=sh