#compdef file_ops

autoload -U is-at-least

_file_ops() {
    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]' \
":: :_file_ops_commands" \
"*::: :->file_ops" \
&& ret=0
    case $state in
    (file_ops)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:file_ops-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[@]}" \
":: :_file_ops__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:file_ops-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[_file_ops_commands] )) ||
_file_ops_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 'file_ops commands' commands "$@"
}
(( $+functions[_file_ops__copy_commands] )) ||
_file_ops__copy_commands() {
    local commands; commands=()
    _describe -t commands 'file_ops copy commands' commands "$@"
}
(( $+functions[_file_ops__help__copy_commands] )) ||
_file_ops__help__copy_commands() {
    local commands; commands=()
    _describe -t commands 'file_ops help copy commands' commands "$@"
}
(( $+functions[_file_ops__help_commands] )) ||
_file_ops__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 'file_ops help commands' commands "$@"
}
(( $+functions[_file_ops__help__help_commands] )) ||
_file_ops__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'file_ops help help commands' commands "$@"
}
(( $+functions[_file_ops__help__hlink_commands] )) ||
_file_ops__help__hlink_commands() {
    local commands; commands=()
    _describe -t commands 'file_ops help hlink commands' commands "$@"
}
(( $+functions[_file_ops__hlink_commands] )) ||
_file_ops__hlink_commands() {
    local commands; commands=()
    _describe -t commands 'file_ops hlink commands' commands "$@"
}
(( $+functions[_file_ops__help__move_commands] )) ||
_file_ops__help__move_commands() {
    local commands; commands=()
    _describe -t commands 'file_ops help move commands' commands "$@"
}
(( $+functions[_file_ops__move_commands] )) ||
_file_ops__move_commands() {
    local commands; commands=()
    _describe -t commands 'file_ops move commands' commands "$@"
}
(( $+functions[_file_ops__help__print-path_commands] )) ||
_file_ops__help__print-path_commands() {
    local commands; commands=()
    _describe -t commands 'file_ops help print-path commands' commands "$@"
}
(( $+functions[_file_ops__print-path_commands] )) ||
_file_ops__print-path_commands() {
    local commands; commands=()
    _describe -t commands 'file_ops print-path commands' commands "$@"
}

_file_ops "$@"
