#compdef hatchzip

autoload -U is-at-least

_hatchzip() {
    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[@]}" : \
'-q[Print only errors and prompts]' \
'--quiet[Print only errors and prompts]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_hatchzip_commands" \
"*::: :->hatchzip" \
&& ret=0
    case $state in
    (hatchzip)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:hatchzip-command-$line[1]:"
        case $line[1] in
            (extract)
_arguments "${_arguments_options[@]}" : \
'-o+[Destination folder \[default\: a folder named after the archive, next to it\]. With several archives, each one is extracted into this folder]:DIR:_files' \
'--output=[Destination folder \[default\: a folder named after the archive, next to it\]. With several archives, each one is extracted into this folder]:DIR:_files' \
'-p+[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'--password=[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'--keep-free=[Disk space reserved during extraction, so the disk never fills completely]:SIZE:_default' \
'--keep-archive[Keep the archive\: extract without removing anything, like a standard extraction. Free space is required for all extracted files]' \
'--replace[Replace files that already exist in the destination folder. They are moved into a .hatchzip-replaced folder there and deleted when the extraction completes]' \
'(--replace)--skip-existing[Keep files that already exist in the destination folder. The archive'\''s copies of them are extracted and then discarded, so when the archive is removed, they are not kept anywhere]' \
'--verify-first[Verify every entry before modifying the archive]' \
'-y[Skip the confirmation prompt (required outside a terminal, unless --keep-archive is given)]' \
'--yes[Skip the confirmation prompt (required outside a terminal, unless --keep-archive is given)]' \
'-q[Print only errors and prompts]' \
'--quiet[Print only errors and prompts]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
'*::archives -- The archive, or any part of a split archive. Several can be given:_files' \
&& ret=0
;;
(x)
_arguments "${_arguments_options[@]}" : \
'-o+[Destination folder \[default\: a folder named after the archive, next to it\]. With several archives, each one is extracted into this folder]:DIR:_files' \
'--output=[Destination folder \[default\: a folder named after the archive, next to it\]. With several archives, each one is extracted into this folder]:DIR:_files' \
'-p+[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'--password=[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'--keep-free=[Disk space reserved during extraction, so the disk never fills completely]:SIZE:_default' \
'--keep-archive[Keep the archive\: extract without removing anything, like a standard extraction. Free space is required for all extracted files]' \
'--replace[Replace files that already exist in the destination folder. They are moved into a .hatchzip-replaced folder there and deleted when the extraction completes]' \
'(--replace)--skip-existing[Keep files that already exist in the destination folder. The archive'\''s copies of them are extracted and then discarded, so when the archive is removed, they are not kept anywhere]' \
'--verify-first[Verify every entry before modifying the archive]' \
'-y[Skip the confirmation prompt (required outside a terminal, unless --keep-archive is given)]' \
'--yes[Skip the confirmation prompt (required outside a terminal, unless --keep-archive is given)]' \
'-q[Print only errors and prompts]' \
'--quiet[Print only errors and prompts]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
'*::archives -- The archive, or any part of a split archive. Several can be given:_files' \
&& ret=0
;;
(check)
_arguments "${_arguments_options[@]}" : \
'-o+[Destination folder \[default\: a folder named after the archive, next to it\]. With several archives, each one is extracted into this folder]:DIR:_files' \
'--output=[Destination folder \[default\: a folder named after the archive, next to it\]. With several archives, each one is extracted into this folder]:DIR:_files' \
'-p+[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'--password=[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'--keep-free=[Disk space reserved during extraction, so the disk never fills completely]:SIZE:_default' \
'--keep-archive[Keep the archive\: extract without removing anything, like a standard extraction. Free space is required for all extracted files]' \
'--replace[Replace files that already exist in the destination folder. They are moved into a .hatchzip-replaced folder there and deleted when the extraction completes]' \
'(--replace)--skip-existing[Keep files that already exist in the destination folder. The archive'\''s copies of them are extracted and then discarded, so when the archive is removed, they are not kept anywhere]' \
'-q[Print only errors and prompts]' \
'--quiet[Print only errors and prompts]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::archives -- The archive, or any part of a split archive. Several can be given:_files' \
&& ret=0
;;
(c)
_arguments "${_arguments_options[@]}" : \
'-o+[Destination folder \[default\: a folder named after the archive, next to it\]. With several archives, each one is extracted into this folder]:DIR:_files' \
'--output=[Destination folder \[default\: a folder named after the archive, next to it\]. With several archives, each one is extracted into this folder]:DIR:_files' \
'-p+[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'--password=[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'--keep-free=[Disk space reserved during extraction, so the disk never fills completely]:SIZE:_default' \
'--keep-archive[Keep the archive\: extract without removing anything, like a standard extraction. Free space is required for all extracted files]' \
'--replace[Replace files that already exist in the destination folder. They are moved into a .hatchzip-replaced folder there and deleted when the extraction completes]' \
'(--replace)--skip-existing[Keep files that already exist in the destination folder. The archive'\''s copies of them are extracted and then discarded, so when the archive is removed, they are not kept anywhere]' \
'-q[Print only errors and prompts]' \
'--quiet[Print only errors and prompts]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::archives -- The archive, or any part of a split archive. Several can be given:_files' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
'-p+[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'--password=[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'-q[Print only errors and prompts]' \
'--quiet[Print only errors and prompts]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::archives -- The archive, or any part of a split archive. Several can be given:_files' \
&& ret=0
;;
(l)
_arguments "${_arguments_options[@]}" : \
'-p+[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'--password=[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'-q[Print only errors and prompts]' \
'--quiet[Print only errors and prompts]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::archives -- The archive, or any part of a split archive. Several can be given:_files' \
&& ret=0
;;
(test)
_arguments "${_arguments_options[@]}" : \
'-p+[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'--password=[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'-q[Print only errors and prompts]' \
'--quiet[Print only errors and prompts]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::archives -- The archive, or any part of a split archive. Several can be given:_files' \
&& ret=0
;;
(t)
_arguments "${_arguments_options[@]}" : \
'-p+[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'--password=[Password for an encrypted archive. If omitted, HatchZip prompts for it with hidden input, which is preferred\: this value is visible to other programs]:PASSWORD:_default' \
'-q[Print only errors and prompts]' \
'--quiet[Print only errors and prompts]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::archives -- The archive, or any part of a split archive. Several can be given:_files' \
&& ret=0
;;
(restore)
_arguments "${_arguments_options[@]}" : \
'-o+[The destination folder the extraction was started with, if it was not the default one]:DIR:_files' \
'--output=[The destination folder the extraction was started with, if it was not the default one]:DIR:_files' \
'-q[Print only errors and prompts]' \
'--quiet[Print only errors and prompts]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
':archive -- The partially extracted archive, or any part of a split archive:_files' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
'-q[Print only errors and prompts]' \
'--quiet[Print only errors and prompts]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
':shell:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(man)
_arguments "${_arguments_options[@]}" : \
'-q[Print only errors and prompts]' \
'--quiet[Print only errors and prompts]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_hatchzip__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:hatchzip-help-command-$line[1]:"
        case $line[1] in
            (extract)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(check)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(test)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(restore)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(man)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_hatchzip_commands] )) ||
_hatchzip_commands() {
    local commands; commands=(
'extract:Extract an archive, removing it progressively' \
'x:Extract an archive, removing it progressively' \
'check:Show the space plan for an archive without modifying it' \
'c:Show the space plan for an archive without modifying it' \
'list:List the entries of an archive' \
'l:List the entries of an archive' \
'test:Verify every entry of an archive without writing files' \
't:Verify every entry of an archive without writing files' \
'restore:Restore a partially extracted archive to a standard archive' \
'completions:Print a shell completion script' \
'man:Print the man page (roff)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'hatchzip commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__check_commands] )) ||
_hatchzip__subcmd__check_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip check commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__completions_commands] )) ||
_hatchzip__subcmd__completions_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip completions commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__extract_commands] )) ||
_hatchzip__subcmd__extract_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip extract commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__help_commands] )) ||
_hatchzip__subcmd__help_commands() {
    local commands; commands=(
'extract:Extract an archive, removing it progressively' \
'check:Show the space plan for an archive without modifying it' \
'list:List the entries of an archive' \
'test:Verify every entry of an archive without writing files' \
'restore:Restore a partially extracted archive to a standard archive' \
'completions:Print a shell completion script' \
'man:Print the man page (roff)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'hatchzip help commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__help__subcmd__check_commands] )) ||
_hatchzip__subcmd__help__subcmd__check_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip help check commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__help__subcmd__completions_commands] )) ||
_hatchzip__subcmd__help__subcmd__completions_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip help completions commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__help__subcmd__extract_commands] )) ||
_hatchzip__subcmd__help__subcmd__extract_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip help extract commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__help__subcmd__help_commands] )) ||
_hatchzip__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip help help commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__help__subcmd__list_commands] )) ||
_hatchzip__subcmd__help__subcmd__list_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip help list commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__help__subcmd__man_commands] )) ||
_hatchzip__subcmd__help__subcmd__man_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip help man commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__help__subcmd__restore_commands] )) ||
_hatchzip__subcmd__help__subcmd__restore_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip help restore commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__help__subcmd__test_commands] )) ||
_hatchzip__subcmd__help__subcmd__test_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip help test commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__list_commands] )) ||
_hatchzip__subcmd__list_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip list commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__man_commands] )) ||
_hatchzip__subcmd__man_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip man commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__restore_commands] )) ||
_hatchzip__subcmd__restore_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip restore commands' commands "$@"
}
(( $+functions[_hatchzip__subcmd__test_commands] )) ||
_hatchzip__subcmd__test_commands() {
    local commands; commands=()
    _describe -t commands 'hatchzip test commands' commands "$@"
}

if [ "$funcstack[1]" = "_hatchzip" ]; then
    _hatchzip "$@"
else
    compdef _hatchzip hatchzip
fi
