#compdef downtools

autoload -U is-at-least

_downtools() {
    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[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
":: :_downtools_commands" \
"*::: :->downtools" \
&& ret=0
    case $state in
    (downtools)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:downtools-command-$line[1]:"
        case $line[1] in
            (print-path)
_arguments "${_arguments_options[@]}" \
'-s+[the source dir to find the files]:SOURCE_DIR:_files' \
'--source-dir=[the source dir to find the files]:SOURCE_DIR:_files' \
'-d+[the target dir to put matched files]:DEST_DIR:_files' \
'--dest-dir=[the target dir to put matched files]:DEST_DIR:_files' \
'-p+[the regex pattern to filter the files]:PATTERN: ' \
'--pattern=[the regex pattern to filter the files]:PATTERN: ' \
'-c[if it is present, the pattern will be case insensitive]' \
'--case-insensitive[if it is present, the pattern will be case insensitive]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(move)
_arguments "${_arguments_options[@]}" \
'-s+[the source dir to find the files]:SOURCE_DIR:_files' \
'--source-dir=[the source dir to find the files]:SOURCE_DIR:_files' \
'-d+[the target dir to put matched files]:DEST_DIR:_files' \
'--dest-dir=[the target dir to put matched files]:DEST_DIR:_files' \
'-p+[the regex pattern to filter the files]:PATTERN: ' \
'--pattern=[the regex pattern to filter the files]:PATTERN: ' \
'-c[if it is present, the pattern will be case insensitive]' \
'--case-insensitive[if it is present, the pattern will be case insensitive]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(hlink)
_arguments "${_arguments_options[@]}" \
'-s+[the source dir to find the files]:SOURCE_DIR:_files' \
'--source-dir=[the source dir to find the files]:SOURCE_DIR:_files' \
'-d+[the target dir to put matched files]:DEST_DIR:_files' \
'--dest-dir=[the target dir to put matched files]:DEST_DIR:_files' \
'-p+[the regex pattern to filter the files]:PATTERN: ' \
'--pattern=[the regex pattern to filter the files]:PATTERN: ' \
'-c[if it is present, the pattern will be case insensitive]' \
'--case-insensitive[if it is present, the pattern will be case insensitive]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(copy)
_arguments "${_arguments_options[@]}" \
'-s+[the source dir to find the files]:SOURCE_DIR:_files' \
'--source-dir=[the source dir to find the files]:SOURCE_DIR:_files' \
'-d+[the target dir to put matched files]:DEST_DIR:_files' \
'--dest-dir=[the target dir to put matched files]:DEST_DIR:_files' \
'-p+[the regex pattern to filter the files]:PATTERN: ' \
'--pattern=[the regex pattern to filter the files]:PATTERN: ' \
'-c[if it is present, the pattern will be case insensitive]' \
'--case-insensitive[if it is present, the pattern will be case insensitive]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
":: :_downtools__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:downtools-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[_downtools_commands] )) ||
_downtools_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 'downtools commands' commands "$@"
}
(( $+functions[_downtools__copy_commands] )) ||
_downtools__copy_commands() {
    local commands; commands=()
    _describe -t commands 'downtools copy commands' commands "$@"
}
(( $+functions[_downtools__help__copy_commands] )) ||
_downtools__help__copy_commands() {
    local commands; commands=()
    _describe -t commands 'downtools help copy commands' commands "$@"
}
(( $+functions[_downtools__help_commands] )) ||
_downtools__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 'downtools help commands' commands "$@"
}
(( $+functions[_downtools__help__help_commands] )) ||
_downtools__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'downtools help help commands' commands "$@"
}
(( $+functions[_downtools__help__hlink_commands] )) ||
_downtools__help__hlink_commands() {
    local commands; commands=()
    _describe -t commands 'downtools help hlink commands' commands "$@"
}
(( $+functions[_downtools__hlink_commands] )) ||
_downtools__hlink_commands() {
    local commands; commands=()
    _describe -t commands 'downtools hlink commands' commands "$@"
}
(( $+functions[_downtools__help__move_commands] )) ||
_downtools__help__move_commands() {
    local commands; commands=()
    _describe -t commands 'downtools help move commands' commands "$@"
}
(( $+functions[_downtools__move_commands] )) ||
_downtools__move_commands() {
    local commands; commands=()
    _describe -t commands 'downtools move commands' commands "$@"
}
(( $+functions[_downtools__help__print-path_commands] )) ||
_downtools__help__print-path_commands() {
    local commands; commands=()
    _describe -t commands 'downtools help print-path commands' commands "$@"
}
(( $+functions[_downtools__print-path_commands] )) ||
_downtools__print-path_commands() {
    local commands; commands=()
    _describe -t commands 'downtools print-path commands' commands "$@"
}

_downtools "$@"
