#compdef mise
# @generated by usage-argv for `mise __complete_word__ --shell zsh`
# Do not edit: regenerate it. Needs no other program, and no cached spec —
# the binary answers from the tables it was compiled with.

_mise() {
    local -a values=() descriptions=() inserts=()
    local __usage_files= __usage_line __usage_menu=0
    # `$BUFFER[1,CURSOR]` is the text before the cursor, cut with zsh's own offset — see the
    # bash script on why the cutting happens here rather than through a `--cursor` argument.
    while IFS= read -r __usage_line; do
        case "$__usage_line" in
            $'\001files') __usage_files=any; continue ;;
            $'\001dirs') __usage_files=dirs; continue ;;
            $'\001executables') __usage_files=executables; continue ;;
            $'\001commands') __usage_files=commands; continue ;;
            '') continue ;;
        esac
        local -a parts=("${(@ps:\t:)__usage_line}")
        values+=("${parts[1]}")
        descriptions+=("${parts[2]}")
        inserts+=("${parts[3]}")
        # A quoted insert means the value needed quoting, and zsh should offer a menu rather
        # than silently inserting one of several possibilities.
        [[ "${parts[3]}" == "'"* ]] && __usage_menu=1
    done < <(command 'mise' __complete_word__ --shell zsh \
        --line "${BUFFER[1,CURSOR]}" 2>/dev/null)

    local __usage_ret=1
    (( __usage_menu )) && compstate[insert]=menu
    if (( ${#inserts[@]} )); then
        local -a display=()
        local i max=0 value pad
        for value in "${values[@]}"; do
            (( ${#value} > max )) && max=${#value}
        done
        for (( i = 1; i <= ${#values[@]}; i++ )); do
            if [[ -n "${descriptions[i]}" ]]; then
                pad=$(( max - ${#values[i]} ))
                display+=("${values[i]}${(l:pad:: :)}  -- ${descriptions[i]}")
            else
                display+=("${values[i]}")
            fi
        done
        # `-U` because the binary already filtered by the typed prefix, and `-Q` because the
        # inserts are quoted already.
        compadd -l -d display -U -Q -S '' -a inserts && __usage_ret=0
    fi

    case "$__usage_files" in
        any) _files && __usage_ret=0 ;;
        dirs) _files -/ && __usage_ret=0 ;;
        executables) _files -g '*(-/,*)' && __usage_ret=0 ;;
        commands) _command_names && __usage_ret=0 ;;
    esac
    return $__usage_ret
}
# Installed either way. Dropped in `$fpath` as `_mise`, compinit autoloads the file and calls
# the function named after it — which is why the function is `_mise` and not something tidier.
# Sourced from a config instead, nothing has called it yet, so it registers itself.
if [ "$funcstack[1]" = "_mise" ]; then
    _mise "$@"
else
    compdef _mise 'mise'
fi
