#compdef air

autoload -U is-at-least

_air() {
    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[@]}" : \
'--log-level=[The log level \[default\: warn\]]:LOG_LEVEL:(error warn info debug trace)' \
'--no-color[Disable colored output. To turn colored output off, either set this option or set the environment variable \`NO_COLOR\` to any non-zero value]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_air_commands" \
"*::: :->air" \
&& ret=0
    case $state in
    (air)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:air-command-$line[1]:"
        case $line[1] in
            (format)
_arguments "${_arguments_options[@]}" : \
'--stdin-file-path=[Use this option to enable reading from stdin and writing to stdout. This specifies a file path to associate the standard input with, which is used as the location to begin searching for configuration files from. The file does not have to exist and will not be read from. If a relative path is provided, it is resolved from the current working directory. If this option is specified, no other files or directories can be provided]:STDIN_FILE_PATH:_files' \
'--log-level=[The log level \[default\: warn\]]:LOG_LEVEL:(error warn info debug trace)' \
'--check[If enabled, format results are not written back to the file. Instead, exit with a non-zero status code if any files would have been modified, and zero otherwise]' \
'--force[Force formatting to occur regardless of exclusion patterns. This applies recursively to directories. This serves as an escape hatch for cases like \`air format r-code.txt --force\`, but is very rarely needed]' \
'--no-color[Disable colored output. To turn colored output off, either set this option or set the environment variable \`NO_COLOR\` to any non-zero value]' \
'-h[Print help]' \
'--help[Print help]' \
'*::paths -- The files or directories to format:_files' \
&& ret=0
;;
(language-server)
_arguments "${_arguments_options[@]}" : \
'--log-level=[The log level \[default\: warn\]]:LOG_LEVEL:(error warn info debug trace)' \
'--no-color[Disable colored output. To turn colored output off, either set this option or set the environment variable \`NO_COLOR\` to any non-zero value]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(generate-shell-completion)
_arguments "${_arguments_options[@]}" : \
'--log-level=[The log level \[default\: warn\]]:LOG_LEVEL:(error warn info debug trace)' \
'--no-color[Disable colored output. To turn colored output off, either set this option or set the environment variable \`NO_COLOR\` to any non-zero value]' \
'-h[Print help]' \
'--help[Print help]' \
':shell -- The shell for which to generate the completion script:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_air__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:air-help-command-$line[1]:"
        case $line[1] in
            (format)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(language-server)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(generate-shell-completion)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_air_commands] )) ||
_air_commands() {
    local commands; commands=(
'format:Format a set of files or directories' \
'language-server:Start a language server' \
'generate-shell-completion:Generate shell completion scripts' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'air commands' commands "$@"
}
(( $+functions[_air__format_commands] )) ||
_air__format_commands() {
    local commands; commands=()
    _describe -t commands 'air format commands' commands "$@"
}
(( $+functions[_air__generate-shell-completion_commands] )) ||
_air__generate-shell-completion_commands() {
    local commands; commands=()
    _describe -t commands 'air generate-shell-completion commands' commands "$@"
}
(( $+functions[_air__help_commands] )) ||
_air__help_commands() {
    local commands; commands=(
'format:Format a set of files or directories' \
'language-server:Start a language server' \
'generate-shell-completion:Generate shell completion scripts' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'air help commands' commands "$@"
}
(( $+functions[_air__help__format_commands] )) ||
_air__help__format_commands() {
    local commands; commands=()
    _describe -t commands 'air help format commands' commands "$@"
}
(( $+functions[_air__help__generate-shell-completion_commands] )) ||
_air__help__generate-shell-completion_commands() {
    local commands; commands=()
    _describe -t commands 'air help generate-shell-completion commands' commands "$@"
}
(( $+functions[_air__help__help_commands] )) ||
_air__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'air help help commands' commands "$@"
}
(( $+functions[_air__help__language-server_commands] )) ||
_air__help__language-server_commands() {
    local commands; commands=()
    _describe -t commands 'air help language-server commands' commands "$@"
}
(( $+functions[_air__language-server_commands] )) ||
_air__language-server_commands() {
    local commands; commands=()
    _describe -t commands 'air language-server commands' commands "$@"
}

if [ "$funcstack[1]" = "_air" ]; then
    _air "$@"
else
    compdef _air air
fi
