#compdef elf2nucleus

autoload -U is-at-least

_elf2nucleus() {
    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[@]}" \
'-t+[Timeout in seconds for micronucleus device discovery]:TIMEOUT: ' \
'--timeout=[Timeout in seconds for micronucleus device discovery]:TIMEOUT: ' \
'--completions=[Generate shell completions]:COMPLETIONS:(bash elvish fish powershell zsh)' \
'*-v[Increase logging output (can be used multiple times)]' \
'*--verbose[Increase logging output (can be used multiple times)]' \
'-h[Print help]' \
'--help[Print help]' \
'::input -- The elf file containing the firmware:_files' \
'::output -- Instead of flashing, write the firmware to file:_files' \
&& ret=0
}

(( $+functions[_elf2nucleus_commands] )) ||
_elf2nucleus_commands() {
    local commands; commands=()
    _describe -t commands 'elf2nucleus commands' commands "$@"
}

if [ "$funcstack[1]" = "_elf2nucleus" ]; then
    _elf2nucleus "$@"
else
    compdef _elf2nucleus elf2nucleus
fi
