• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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'-o+[cmd option]: : ' \
19'-O+[cmd option]: : ' \
20'--option=[cmd option]: : ' \
21'--opt=[cmd option]: : ' \
22'-f[cmd flag]' \
23'-F[cmd flag]' \
24'--flag[cmd flag]' \
25'--flg[cmd flag]' \
26'-h[Print help]' \
27'--help[Print help]' \
28'-V[Print version]' \
29'--version[Print version]' \
30'::positional:' \
31&& ret=0
32}
33
34(( $+functions[_my-app_commands] )) ||
35_my-app_commands() {
36    local commands; commands=()
37    _describe -t commands 'my-app commands' commands "$@"
38}
39
40if [ "$funcstack[1]" = "_my-app" ]; then
41    _my-app "$@"
42else
43    compdef _my-app my-app
44fi
45