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'--single-quotes[Can be '\''always'\'', '\''auto'\'', or '\''never'\'']' \ 19'--double-quotes[Can be "always", "auto", or "never"]' \ 20'--backticks[For more information see `echo test`]' \ 21'--backslash[Avoid '\''\\n'\'']' \ 22'--brackets[List packages \[filter\]]' \ 23'--expansions[Execute the shell command with $SHELL]' \ 24'-h[Print help]' \ 25'--help[Print help]' \ 26'-V[Print version]' \ 27'--version[Print version]' \ 28":: :_my-app_commands" \ 29"*::: :->my-app" \ 30&& ret=0 31 case $state in 32 (my-app) 33 words=($line[1] "${words[@]}") 34 (( CURRENT += 1 )) 35 curcontext="${curcontext%:*:*}:my-app-command-$line[1]:" 36 case $line[1] in 37 (cmd-single-quotes) 38_arguments "${_arguments_options[@]}" \ 39'-h[Print help]' \ 40'--help[Print help]' \ 41&& ret=0 42;; 43(cmd-double-quotes) 44_arguments "${_arguments_options[@]}" \ 45'-h[Print help]' \ 46'--help[Print help]' \ 47&& ret=0 48;; 49(cmd-backticks) 50_arguments "${_arguments_options[@]}" \ 51'-h[Print help]' \ 52'--help[Print help]' \ 53&& ret=0 54;; 55(cmd-backslash) 56_arguments "${_arguments_options[@]}" \ 57'-h[Print help]' \ 58'--help[Print help]' \ 59&& ret=0 60;; 61(cmd-brackets) 62_arguments "${_arguments_options[@]}" \ 63'-h[Print help]' \ 64'--help[Print help]' \ 65&& ret=0 66;; 67(cmd-expansions) 68_arguments "${_arguments_options[@]}" \ 69'-h[Print help]' \ 70'--help[Print help]' \ 71&& ret=0 72;; 73(help) 74_arguments "${_arguments_options[@]}" \ 75":: :_my-app__help_commands" \ 76"*::: :->help" \ 77&& ret=0 78 79 case $state in 80 (help) 81 words=($line[1] "${words[@]}") 82 (( CURRENT += 1 )) 83 curcontext="${curcontext%:*:*}:my-app-help-command-$line[1]:" 84 case $line[1] in 85 (cmd-single-quotes) 86_arguments "${_arguments_options[@]}" \ 87&& ret=0 88;; 89(cmd-double-quotes) 90_arguments "${_arguments_options[@]}" \ 91&& ret=0 92;; 93(cmd-backticks) 94_arguments "${_arguments_options[@]}" \ 95&& ret=0 96;; 97(cmd-backslash) 98_arguments "${_arguments_options[@]}" \ 99&& ret=0 100;; 101(cmd-brackets) 102_arguments "${_arguments_options[@]}" \ 103&& ret=0 104;; 105(cmd-expansions) 106_arguments "${_arguments_options[@]}" \ 107&& ret=0 108;; 109(help) 110_arguments "${_arguments_options[@]}" \ 111&& ret=0 112;; 113 esac 114 ;; 115esac 116;; 117 esac 118 ;; 119esac 120} 121 122(( $+functions[_my-app_commands] )) || 123_my-app_commands() { 124 local commands; commands=( 125'cmd-single-quotes:Can be '\''always'\'', '\''auto'\'', or '\''never'\''' \ 126'cmd-double-quotes:Can be "always", "auto", or "never"' \ 127'cmd-backticks:For more information see `echo test`' \ 128'cmd-backslash:Avoid '\''\\n'\''' \ 129'cmd-brackets:List packages \[filter\]' \ 130'cmd-expansions:Execute the shell command with $SHELL' \ 131'help:Print this message or the help of the given subcommand(s)' \ 132 ) 133 _describe -t commands 'my-app commands' commands "$@" 134} 135(( $+functions[_my-app__cmd-backslash_commands] )) || 136_my-app__cmd-backslash_commands() { 137 local commands; commands=() 138 _describe -t commands 'my-app cmd-backslash commands' commands "$@" 139} 140(( $+functions[_my-app__help__cmd-backslash_commands] )) || 141_my-app__help__cmd-backslash_commands() { 142 local commands; commands=() 143 _describe -t commands 'my-app help cmd-backslash commands' commands "$@" 144} 145(( $+functions[_my-app__cmd-backticks_commands] )) || 146_my-app__cmd-backticks_commands() { 147 local commands; commands=() 148 _describe -t commands 'my-app cmd-backticks commands' commands "$@" 149} 150(( $+functions[_my-app__help__cmd-backticks_commands] )) || 151_my-app__help__cmd-backticks_commands() { 152 local commands; commands=() 153 _describe -t commands 'my-app help cmd-backticks commands' commands "$@" 154} 155(( $+functions[_my-app__cmd-brackets_commands] )) || 156_my-app__cmd-brackets_commands() { 157 local commands; commands=() 158 _describe -t commands 'my-app cmd-brackets commands' commands "$@" 159} 160(( $+functions[_my-app__help__cmd-brackets_commands] )) || 161_my-app__help__cmd-brackets_commands() { 162 local commands; commands=() 163 _describe -t commands 'my-app help cmd-brackets commands' commands "$@" 164} 165(( $+functions[_my-app__cmd-double-quotes_commands] )) || 166_my-app__cmd-double-quotes_commands() { 167 local commands; commands=() 168 _describe -t commands 'my-app cmd-double-quotes commands' commands "$@" 169} 170(( $+functions[_my-app__help__cmd-double-quotes_commands] )) || 171_my-app__help__cmd-double-quotes_commands() { 172 local commands; commands=() 173 _describe -t commands 'my-app help cmd-double-quotes commands' commands "$@" 174} 175(( $+functions[_my-app__cmd-expansions_commands] )) || 176_my-app__cmd-expansions_commands() { 177 local commands; commands=() 178 _describe -t commands 'my-app cmd-expansions commands' commands "$@" 179} 180(( $+functions[_my-app__help__cmd-expansions_commands] )) || 181_my-app__help__cmd-expansions_commands() { 182 local commands; commands=() 183 _describe -t commands 'my-app help cmd-expansions commands' commands "$@" 184} 185(( $+functions[_my-app__cmd-single-quotes_commands] )) || 186_my-app__cmd-single-quotes_commands() { 187 local commands; commands=() 188 _describe -t commands 'my-app cmd-single-quotes commands' commands "$@" 189} 190(( $+functions[_my-app__help__cmd-single-quotes_commands] )) || 191_my-app__help__cmd-single-quotes_commands() { 192 local commands; commands=() 193 _describe -t commands 'my-app help cmd-single-quotes commands' commands "$@" 194} 195(( $+functions[_my-app__help_commands] )) || 196_my-app__help_commands() { 197 local commands; commands=( 198'cmd-single-quotes:Can be '\''always'\'', '\''auto'\'', or '\''never'\''' \ 199'cmd-double-quotes:Can be "always", "auto", or "never"' \ 200'cmd-backticks:For more information see `echo test`' \ 201'cmd-backslash:Avoid '\''\\n'\''' \ 202'cmd-brackets:List packages \[filter\]' \ 203'cmd-expansions:Execute the shell command with $SHELL' \ 204'help:Print this message or the help of the given subcommand(s)' \ 205 ) 206 _describe -t commands 'my-app help commands' commands "$@" 207} 208(( $+functions[_my-app__help__help_commands] )) || 209_my-app__help__help_commands() { 210 local commands; commands=() 211 _describe -t commands 'my-app help help commands' commands "$@" 212} 213 214_my-app "$@" 215