#compdef alpm-lint

autoload -U is-at-least

_alpm-lint() {
    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[@]}" : \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_alpm-lint_commands" \
"*::: :->alpm-lint" \
&& ret=0
    case $state in
    (alpm-lint)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:alpm-lint-command-$line[1]:"
        case $line[1] in
            (check)
_arguments "${_arguments_options[@]}" : \
'-s+[Explicitly define the linting scope]:SCOPE:((source-repository\:"Lint rules with this scope are specific to an \[alpm-source-repo\]"
package\:"Lint rules with this scope are specific to an \[alpm-package\]"
build-info\:"Lint rules with this scope are specific to a single \[BUILDINFO\] file"
package-build\:"Lint rules with this scope are specific to a single \[PKGBUILD\] file"
package-info\:"Lint rules with this scope are specific to a single \[PKGINFO\] file"
source-info\:"Lint rules with this scope are specific to a single \[SRCINFO\] file"))' \
'--scope=[Explicitly define the linting scope]:SCOPE:((source-repository\:"Lint rules with this scope are specific to an \[alpm-source-repo\]"
package\:"Lint rules with this scope are specific to an \[alpm-package\]"
build-info\:"Lint rules with this scope are specific to a single \[BUILDINFO\] file"
package-build\:"Lint rules with this scope are specific to a single \[PKGBUILD\] file"
package-info\:"Lint rules with this scope are specific to a single \[PKGINFO\] file"
source-info\:"Lint rules with this scope are specific to a single \[SRCINFO\] file"))' \
'-f+[The output format to use]:CHECK_FORMAT:((text\:"Human readable text"
json\:"The JSON output format"))' \
'--format=[The output format to use]:CHECK_FORMAT:((text\:"Human readable text"
json\:"The JSON output format"))' \
'-l+[The level of lints to consider]:LEVEL:((error\:"Lint rules leading to errors"
deny\:"Lint rules leading to denials"
warn\:"Lint rules leading to warnings"
suggest\:"Lint rules leading to suggestions"))' \
'--level=[The level of lints to consider]:LEVEL:((error\:"Lint rules leading to errors"
deny\:"Lint rules leading to denials"
warn\:"Lint rules leading to warnings"
suggest\:"Lint rules leading to suggestions"))' \
'-c+[Supply a lint config path]:LEVEL:_files' \
'--config=[Supply a lint config path]:LEVEL:_files' \
'-o+[Optional output file path. If not provided, output goes to stdout]:FILE:_files' \
'--output=[Optional output file path. If not provided, output goes to stdout]:FILE:_files' \
'-p[Pretty-print the output]' \
'--pretty[Pretty-print the output]' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::path -- An optional path to a file or directory to be linted:_files' \
&& ret=0
;;
(rules)
_arguments "${_arguments_options[@]}" : \
'-f+[The output format to use]:FORMAT:((json\:"The JSON output format"))' \
'--format=[The output format to use]:FORMAT:((json\:"The JSON output format"))' \
'-o+[Optional output file path]:FILE:_files' \
'--output=[Optional output file path]:FILE:_files' \
'-p[Pretty-print the output]' \
'--pretty[Pretty-print the output]' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(options)
_arguments "${_arguments_options[@]}" : \
'-f+[The output format to use]:FORMAT:((json\:"The JSON output format"))' \
'--format=[The output format to use]:FORMAT:((json\:"The JSON output format"))' \
'-o+[Optional output file path]:FILE:_files' \
'--output=[Optional output file path]:FILE:_files' \
'-p[Pretty-print the output]' \
'--pretty[Pretty-print the output]' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(meta)
_arguments "${_arguments_options[@]}" : \
'-f+[The output format to use]:FORMAT:((json\:"The JSON output format"))' \
'--format=[The output format to use]:FORMAT:((json\:"The JSON output format"))' \
'-o+[Optional output file path]:FILE:_files' \
'--output=[Optional output file path]:FILE:_files' \
'-p[Pretty-print the output]' \
'--pretty[Pretty-print the output]' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_alpm-lint__help_commands" \
"*::: :->help" \
&& ret=0

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

(( $+functions[_alpm-lint_commands] )) ||
_alpm-lint_commands() {
    local commands; commands=(
'check:Run lints on a file or directory' \
'rules:Return the definition of all lint rules as structured data' \
'options:Return the definition of all options to configure individual linting rules' \
'meta:Return metadata about available lint groups, scopes, and levels for static site generators' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'alpm-lint commands' commands "$@"
}
(( $+functions[_alpm-lint__check_commands] )) ||
_alpm-lint__check_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-lint check commands' commands "$@"
}
(( $+functions[_alpm-lint__help_commands] )) ||
_alpm-lint__help_commands() {
    local commands; commands=(
'check:Run lints on a file or directory' \
'rules:Return the definition of all lint rules as structured data' \
'options:Return the definition of all options to configure individual linting rules' \
'meta:Return metadata about available lint groups, scopes, and levels for static site generators' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'alpm-lint help commands' commands "$@"
}
(( $+functions[_alpm-lint__help__check_commands] )) ||
_alpm-lint__help__check_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-lint help check commands' commands "$@"
}
(( $+functions[_alpm-lint__help__help_commands] )) ||
_alpm-lint__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-lint help help commands' commands "$@"
}
(( $+functions[_alpm-lint__help__meta_commands] )) ||
_alpm-lint__help__meta_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-lint help meta commands' commands "$@"
}
(( $+functions[_alpm-lint__help__options_commands] )) ||
_alpm-lint__help__options_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-lint help options commands' commands "$@"
}
(( $+functions[_alpm-lint__help__rules_commands] )) ||
_alpm-lint__help__rules_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-lint help rules commands' commands "$@"
}
(( $+functions[_alpm-lint__meta_commands] )) ||
_alpm-lint__meta_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-lint meta commands' commands "$@"
}
(( $+functions[_alpm-lint__options_commands] )) ||
_alpm-lint__options_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-lint options commands' commands "$@"
}
(( $+functions[_alpm-lint__rules_commands] )) ||
_alpm-lint__rules_commands() {
    local commands; commands=()
    _describe -t commands 'alpm-lint rules commands' commands "$@"
}

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