#compdef alpm-mtree

autoload -U is-at-least

_alpm-mtree() {
    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]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_alpm-mtree_commands" \
"*::: :->alpm-mtree" \
&& ret=0
    case $state in
    (alpm-mtree)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:alpm-mtree-command-$line[1]:"
        case $line[1] in
            (format)
_arguments "${_arguments_options[@]}" : \
'-s+[Provide the MTREE schema version to use]:VERSION:_default' \
'--schema=[Provide the MTREE schema version to use]:VERSION:_default' \
'-o+[Provide the output format]:OUTPUT_FORMAT:((json\:"The JSON output format"))' \
'--output-format=[Provide the output format]:OUTPUT_FORMAT:((json\:"The JSON output format"))' \
'-p[Determines whether the output will be displayed in a pretty non-minimized fashion]' \
'--pretty[Determines whether the output will be displayed in a pretty non-minimized fashion]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::file -- An optional file to read from:_files' \
&& ret=0
;;
(validate)
_arguments "${_arguments_options[@]}" : \
'-s+[Provide the MTREE schema version to use]:VERSION:_default' \
'--schema=[Provide the MTREE schema version to use]:VERSION:_default' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::file -- An optional file to read from:_files' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_alpm-mtree__help_commands" \
"*::: :->help" \
&& ret=0

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

(( $+functions[_alpm-mtree_commands] )) ||
_alpm-mtree_commands() {
    local commands; commands=(
'format:Read an MTREE file and return it in another file format' \
'validate:Validate an MTREE file' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'alpm-mtree commands' commands "$@"
}
(( $+functions[_alpm-mtree__format_commands] )) ||
_alpm-mtree__format_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-mtree format commands' commands "$@"
}
(( $+functions[_alpm-mtree__help_commands] )) ||
_alpm-mtree__help_commands() {
    local commands; commands=(
'format:Read an MTREE file and return it in another file format' \
'validate:Validate an MTREE file' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'alpm-mtree help commands' commands "$@"
}
(( $+functions[_alpm-mtree__help__format_commands] )) ||
_alpm-mtree__help__format_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-mtree help format commands' commands "$@"
}
(( $+functions[_alpm-mtree__help__help_commands] )) ||
_alpm-mtree__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-mtree help help commands' commands "$@"
}
(( $+functions[_alpm-mtree__help__validate_commands] )) ||
_alpm-mtree__help__validate_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-mtree help validate commands' commands "$@"
}
(( $+functions[_alpm-mtree__validate_commands] )) ||
_alpm-mtree__validate_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-mtree validate commands' commands "$@"
}

if [ "$funcstack[1]" = "_alpm-mtree" ]; then
    _alpm-mtree "$@"
else
    compdef _alpm-mtree alpm-mtree
fi
