1#compdef my-app 2 3autoload -U is-at-least 4 5_my-app() { 6 typeset -A opt_args 7 typeset -a _arguments_options 8 local ret=1 9 10 if is-at-least 5.2; then 11 _arguments_options=(-s -S -C) 12 else 13 _arguments_options=(-s -C) 14 fi 15 16 local context curcontext="$curcontext" state line 17 _arguments "${_arguments_options[@]}" \ 18'-h[Print help]' \ 19'--help[Print help]' \ 20'*;::arguments -- multi-valued argument with a value terminator:' \ 21&& ret=0 22} 23 24(( $+functions[_my-app_commands] )) || 25_my-app_commands() { 26 local commands; commands=() 27 _describe -t commands 'my-app commands' commands "$@" 28} 29 30if [ "$funcstack[1]" = "_my-app" ]; then 31 _my-app "$@" 32else 33 compdef _my-app my-app 34fi 35