#compdef flavours

autoload -U is-at-least

_flavours() {
    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[@]}" \
'-c+[Specify a configuration file (Defaults to ~/.config/flavours/config.toml on Linux)]: :_files' \
'--config=[Specify a configuration file (Defaults to ~/.config/flavours/config.toml on Linux)]: :_files' \
'-d+[Specify a data directory (Defaults to ~/.local/share/flavours on Linux)]: :_files -/' \
'--directory=[Specify a data directory (Defaults to ~/.local/share/flavours on Linux)]: :_files -/' \
'--completions=[Generates completion for given shell, outputs to stdout]: :(bash elvish fish powershell zsh)' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'-v[Be more verbose]' \
'--verbose[Be more verbose]' \
":: :_flavours_commands" \
"*::: :->flavours" \
&& ret=0
    case $state in
    (flavours)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:flavours-command-$line[1]:"
        case $line[1] in
            (current)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" \
'-t[List templates instead of schemes]' \
'--templates[List templates instead of schemes]' \
'-l[Print each scheme on its own line]' \
'--lines[Print each scheme on its own line]' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'*::pattern -- Scheme name or glob pattern to match when listing scheme(s). If ommited, defaults to * (all installed schemes).:($(flavours list))' \
&& ret=0
;;
(info)
_arguments "${_arguments_options[@]}" \
'-r[Don'\''t pretty print the colors.]' \
'--raw[Don'\''t pretty print the colors.]' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'*::pattern -- Scheme name or glob pattern to match when showing scheme(s). If ommited, defaults to * (all installed schemes).:($(flavours list))' \
&& ret=0
;;
(generate)
_arguments "${_arguments_options[@]}" \
'-s+[Scheme slug (the name you specify when applying schemes) to output to. If ommited, defaults to '\''generated'\'']: :($(flavours list))' \
'--slug=[Scheme slug (the name you specify when applying schemes) to output to. If ommited, defaults to '\''generated'\'']: :($(flavours list))' \
'-n+[Scheme display name (can include spaces and capitalization) to write, defaults to '\''Generated'\'']: :( )' \
'--name=[Scheme display name (can include spaces and capitalization) to write, defaults to '\''Generated'\'']: :( )' \
'-a+[Scheme author info (name, email, etc) to write, defaults to '\''Flavours'\'']: :( )' \
'--author=[Scheme author info (name, email, etc) to write, defaults to '\''Flavours'\'']: :( )' \
'--stdout[Outputs scheme to stdout instead of writing it to a file.]' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
':mode -- Whether to generate a dark or light scheme:(dark light)' \
':file -- Which image file to use.:_files' \
&& ret=0
;;
(apply)
_arguments "${_arguments_options[@]}" \
'-l[Skip running heavier hooks (entries marked '\''light=false'\'')]' \
'--light[Skip running heavier hooks (entries marked '\''light=false'\'')]' \
'--stdin[Reads scheme from stdin instead of from flavours directory.]' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'*::pattern -- Scheme to be applied, supports glob. If more than one is specified (or if glob pattern matched more than one), chooses one randomly. If ommited, defaults to * (all installed schemes).:($(flavours list))' \
&& ret=0
;;
(update)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
':operation -- Update sources lists from repositories or (re)download schemes/templates specified in the lists. Default repositories for lists, and the lists themselves, can be manually changed.:(lists schemes templates all)' \
&& ret=0
;;
(build)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
':scheme -- Path to scheme file.:_files' \
':template -- Path to template file.:_files' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_flavours_commands] )) ||
_flavours_commands() {
    local commands; commands=(
'current:Prints last applied scheme name' \
'list:Prints a list with all matching schemes' \
'info:Shows scheme colors for all schemes matching pattern. Optionally uses truecolor' \
'generate:Generates a scheme based on an image' \
'apply:Applies scheme, according to user configuration' \
'update:Downloads schemes, templates, or updates their lists (from repos specified in sources.yml)' \
'build:Builds a template with given scheme, outputs to stdout' \
    )
    _describe -t commands 'flavours commands' commands "$@"
}
(( $+functions[_flavours__apply_commands] )) ||
_flavours__apply_commands() {
    local commands; commands=()
    _describe -t commands 'flavours apply commands' commands "$@"
}
(( $+functions[_flavours__build_commands] )) ||
_flavours__build_commands() {
    local commands; commands=()
    _describe -t commands 'flavours build commands' commands "$@"
}
(( $+functions[_flavours__current_commands] )) ||
_flavours__current_commands() {
    local commands; commands=()
    _describe -t commands 'flavours current commands' commands "$@"
}
(( $+functions[_flavours__generate_commands] )) ||
_flavours__generate_commands() {
    local commands; commands=()
    _describe -t commands 'flavours generate commands' commands "$@"
}
(( $+functions[_flavours__info_commands] )) ||
_flavours__info_commands() {
    local commands; commands=()
    _describe -t commands 'flavours info commands' commands "$@"
}
(( $+functions[_flavours__list_commands] )) ||
_flavours__list_commands() {
    local commands; commands=()
    _describe -t commands 'flavours list commands' commands "$@"
}
(( $+functions[_flavours__update_commands] )) ||
_flavours__update_commands() {
    local commands; commands=()
    _describe -t commands 'flavours update commands' commands "$@"
}

_flavours "$@"
