#compdef tools autoload -U is-at-least _tools() { typeset -A opt_args typeset -a _arguments_options local ret=1 if is-at-least 5.2; then _arguments_options=(-s -S -C) else _arguments_options=(-s -C) fi local context curcontext="$curcontext" state line _arguments "${_arguments_options[@]}" \ '-p+[The path to the directory to walk]:PATH:_files' \ '--path=[The path to the directory to walk]:PATH:_files' \ '-h[Print help information]' \ '--help[Print help information]' \ '-V[Print version information]' \ '--version[Print version information]' \ ":: :_tools_commands" \ "*::: :->tools" \ && ret=0 case $state in (tools) words=($line[1] "${words[@]}") (( CURRENT += 1 )) curcontext="${curcontext%:*:*}:tools-command-$line[1]:" case $line[1] in (print-path) _arguments "${_arguments_options[@]}" \ '-h[Print help information]' \ '--help[Print help information]' \ && ret=0 ;; (move) _arguments "${_arguments_options[@]}" \ '-s+[]:SOURCE_DIR:_files' \ '--source-dir=[]:SOURCE_DIR:_files' \ '-d+[]:DEST_DIR:_files' \ '--dest-dir=[]:DEST_DIR:_files' \ '-p+[]:PATTERN: ' \ '--pattern=[]:PATTERN: ' \ '-h[Print help information]' \ '--help[Print help information]' \ && ret=0 ;; (hlink) _arguments "${_arguments_options[@]}" \ '-s+[]:SOURCE_DIR:_files' \ '--source-dir=[]:SOURCE_DIR:_files' \ '-d+[]:DEST_DIR:_files' \ '--dest-dir=[]:DEST_DIR:_files' \ '-p+[]:PATTERN: ' \ '--pattern=[]:PATTERN: ' \ '-h[Print help information]' \ '--help[Print help information]' \ && ret=0 ;; (copy) _arguments "${_arguments_options[@]}" \ '-s+[]:SOURCE_DIR:_files' \ '--source-dir=[]:SOURCE_DIR:_files' \ '-d+[]:DEST_DIR:_files' \ '--dest-dir=[]:DEST_DIR:_files' \ '-p+[]:PATTERN: ' \ '--pattern=[]:PATTERN: ' \ '-h[Print help information]' \ '--help[Print help information]' \ && ret=0 ;; (help) _arguments "${_arguments_options[@]}" \ ":: :_tools__help_commands" \ "*::: :->help" \ && ret=0 case $state in (help) words=($line[1] "${words[@]}") (( CURRENT += 1 )) curcontext="${curcontext%:*:*}:tools-help-command-$line[1]:" case $line[1] in (print-path) _arguments "${_arguments_options[@]}" \ && ret=0 ;; (move) _arguments "${_arguments_options[@]}" \ && ret=0 ;; (hlink) _arguments "${_arguments_options[@]}" \ && ret=0 ;; (copy) _arguments "${_arguments_options[@]}" \ && ret=0 ;; (help) _arguments "${_arguments_options[@]}" \ && ret=0 ;; esac ;; esac ;; esac ;; esac } (( $+functions[_tools_commands] )) || _tools_commands() { local commands; commands=( 'print-path:Prints the path to the directory to walk' \ 'move:move the maching files to destination' \ 'hlink:hardlink' \ 'copy:copy' \ 'help:Print this message or the help of the given subcommand(s)' \ ) _describe -t commands 'tools commands' commands "$@" } (( $+functions[_tools__copy_commands] )) || _tools__copy_commands() { local commands; commands=() _describe -t commands 'tools copy commands' commands "$@" } (( $+functions[_tools__help__copy_commands] )) || _tools__help__copy_commands() { local commands; commands=() _describe -t commands 'tools help copy commands' commands "$@" } (( $+functions[_tools__help_commands] )) || _tools__help_commands() { local commands; commands=( 'print-path:Prints the path to the directory to walk' \ 'move:move the maching files to destination' \ 'hlink:hardlink' \ 'copy:copy' \ 'help:Print this message or the help of the given subcommand(s)' \ ) _describe -t commands 'tools help commands' commands "$@" } (( $+functions[_tools__help__help_commands] )) || _tools__help__help_commands() { local commands; commands=() _describe -t commands 'tools help help commands' commands "$@" } (( $+functions[_tools__help__hlink_commands] )) || _tools__help__hlink_commands() { local commands; commands=() _describe -t commands 'tools help hlink commands' commands "$@" } (( $+functions[_tools__hlink_commands] )) || _tools__hlink_commands() { local commands; commands=() _describe -t commands 'tools hlink commands' commands "$@" } (( $+functions[_tools__help__move_commands] )) || _tools__help__move_commands() { local commands; commands=() _describe -t commands 'tools help move commands' commands "$@" } (( $+functions[_tools__move_commands] )) || _tools__move_commands() { local commands; commands=() _describe -t commands 'tools move commands' commands "$@" } (( $+functions[_tools__help__print-path_commands] )) || _tools__help__print-path_commands() { local commands; commands=() _describe -t commands 'tools help print-path commands' commands "$@" } (( $+functions[_tools__print-path_commands] )) || _tools__print-path_commands() { local commands; commands=() _describe -t commands 'tools print-path commands' commands "$@" } _tools "$@"