#compdef waj

autoload -U is-at-least

_waj() {
    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[@]}" : \
'--generate-man-page=[]' \
'--generate-complete=[]:GENERATE_COMPLETE:(bash elvish fish powershell zsh)' \
'*-v[Set verbose level. Can be specify several times to augment verbose level]' \
'*--verbose[Set verbose level. Can be specify several times to augment verbose level]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_waj_commands" \
"*::: :->waj" \
&& ret=0
    case $state in
    (waj)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:waj-command-$line[1]:"
        case $line[1] in
            (create)
_arguments "${_arguments_options[@]}" : \
'-o+[File path of the archive to create]:OUTFILE:_files' \
'--outfile=[File path of the archive to create]:OUTFILE:_files' \
'--strip-prefix=[Remove STRIP_PREFIX from the entries'\'' name added to the archive]:STRIP_PREFIX:_files -/' \
'-C+[Move to BASE_DIR before starting adding content to arx archive]:BASE_DIR:_files -/' \
'-L+[Get the list of files/directories to add from the FILE_LIST (incompatible with INFILES)]:FILE_LIST:_files' \
'--file-list=[Get the list of files/directories to add from the FILE_LIST (incompatible with INFILES)]:FILE_LIST:_files' \
'-c+[Set compression algorithm to use]:COMPRESSION:_default' \
'--compression=[Set compression algorithm to use]:COMPRESSION:_default' \
'-m+[]:MAIN:_default' \
'--main=[]:MAIN:_default' \
'-1[Create only one file (default)]' \
'--one-file[Create only one file (default)]' \
'-2[Create two files (a content pack and other)]' \
'--two-files[Create two files (a content pack and other)]' \
'-N[Create mulitples files (one per pack)]' \
'--multiple-files[Create mulitples files (one per pack)]' \
'--list-compressions[List available compression algorithms]' \
'-f[]' \
'--force[]' \
'*-v[Set verbose level. Can be specify several times to augment verbose level]' \
'*--verbose[Set verbose level. Can be specify several times to augment verbose level]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::infiles -- Input files/directories:_files' \
&& ret=0
;;
(serve)
_arguments "${_arguments_options[@]}" : \
'-a+[On which address serve the archive]:ADDRESS:_default' \
'--address=[On which address serve the archive]:ADDRESS:_default' \
'-t+[Number of threads to use to answer request]:THREADS:_default' \
'--threads=[Number of threads to use to answer request]:THREADS:_default' \
'--router=[]:ROUTER:(host path)' \
'*-v[Set verbose level. Can be specify several times to augment verbose level]' \
'*--verbose[Set verbose level. Can be specify several times to augment verbose level]' \
'-h[Print help]' \
'--help[Print help]' \
'*::infiles -- Archive to serve:_files' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
'*-v[Set verbose level. Can be specify several times to augment verbose level]' \
'*--verbose[Set verbose level. Can be specify several times to augment verbose level]' \
'-h[Print help]' \
'--help[Print help]' \
':infile -- Archive to read:_files' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_waj__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:waj-help-command-$line[1]:"
        case $line[1] in
            (create)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(serve)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_waj_commands] )) ||
_waj_commands() {
    local commands; commands=(
'create:Parse different flags to select the concat mode' \
'serve:Serve the waj archive on the web' \
'list:List the content in the archive' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'waj commands' commands "$@"
}
(( $+functions[_waj__create_commands] )) ||
_waj__create_commands() {
    local commands; commands=()
    _describe -t commands 'waj create commands' commands "$@"
}
(( $+functions[_waj__help_commands] )) ||
_waj__help_commands() {
    local commands; commands=(
'create:Parse different flags to select the concat mode' \
'serve:Serve the waj archive on the web' \
'list:List the content in the archive' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'waj help commands' commands "$@"
}
(( $+functions[_waj__help__create_commands] )) ||
_waj__help__create_commands() {
    local commands; commands=()
    _describe -t commands 'waj help create commands' commands "$@"
}
(( $+functions[_waj__help__help_commands] )) ||
_waj__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'waj help help commands' commands "$@"
}
(( $+functions[_waj__help__list_commands] )) ||
_waj__help__list_commands() {
    local commands; commands=()
    _describe -t commands 'waj help list commands' commands "$@"
}
(( $+functions[_waj__help__serve_commands] )) ||
_waj__help__serve_commands() {
    local commands; commands=()
    _describe -t commands 'waj help serve commands' commands "$@"
}
(( $+functions[_waj__list_commands] )) ||
_waj__list_commands() {
    local commands; commands=()
    _describe -t commands 'waj list commands' commands "$@"
}
(( $+functions[_waj__serve_commands] )) ||
_waj__serve_commands() {
    local commands; commands=()
    _describe -t commands 'waj serve commands' commands "$@"
}

if [ "$funcstack[1]" = "_waj" ]; then
    _waj "$@"
else
    compdef _waj waj
fi
