#compdef cdist _cdist() { local curcontext="$curcontext" state line typeset -A opt_args _arguments \ '1: :->opts_cmds'\ '*: :->opts' case $state in opts_cmds) _arguments '1:Options and commands:(banner config shell -h --help -d --debug -v --verbose -V --version)' ;; *) case $words[2] in -*) opts=(-h --help -d --debug -v --verbose -V --version) compadd "$@" -- $opts ;; banner) opts=(-h --help -d --debug -v --verbose) compadd "$@" -- $opts ;; shell) case $words[3] in -s|--shell) shells=($(grep -v '^#' /etc/shells)) compadd "$@" -- $shells ;; *) opts=(-h --help -d --debug -v --verbose -s --shell) compadd "$@" -- $opts ;; esac ;; config) opts=(-h --help -d --debug -v --verbose -c --conf-dir -f --file -i --initial-manifest -n --dry-run -o --out-dir -p --parallel -s --sequential --remote-copy --remote-exec) compadd "$@" -- $opts ;; *) ;; esac esac } _cdist "$@"