#compdef spytrap-adb

autoload -U is-at-least

_spytrap-adb() {
    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[@]}" : \
'--start-adb-server=[Configure if an adb server should be started if needed]:choice:(auto always never)' \
'*-v[More verbose logs]' \
'*--verbose[More verbose logs]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_spytrap-adb_commands" \
"*::: :->spytrap-adb" \
&& ret=0
    case $state in
    (spytrap-adb)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:spytrap-adb-command-$line[1]:"
        case $line[1] in
            (scan)
_arguments "${_arguments_options[@]}" : \
'*--rules=[Use specific rule files instead of latest downloaded]:RULES:_files' \
'--start-adb-server=[Configure if an adb server should be started if needed]:choice:(auto always never)' \
'--test-load-only[]' \
'--skip-apps[Do not scan apps for suspicious permissions]' \
'*-v[More verbose logs]' \
'*--verbose[More verbose logs]' \
'-h[Print help]' \
'--help[Print help]' \
'::serial:_default' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
'--start-adb-server=[Configure if an adb server should be started if needed]:choice:(auto always never)' \
'*-v[More verbose logs]' \
'*--verbose[More verbose logs]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(download-ioc)
_arguments "${_arguments_options[@]}" : \
'--start-adb-server=[Configure if an adb server should be started if needed]:choice:(auto always never)' \
'*-v[More verbose logs]' \
'*--verbose[More verbose logs]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
'--start-adb-server=[Configure if an adb server should be started if needed]:choice:(auto always never)' \
'*-v[More verbose logs]' \
'*--verbose[More verbose logs]' \
'-h[Print help]' \
'--help[Print help]' \
':shell:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_spytrap-adb__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:spytrap-adb-help-command-$line[1]:"
        case $line[1] in
            (scan)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(download-ioc)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_spytrap-adb_commands] )) ||
_spytrap-adb_commands() {
    local commands; commands=(
'scan:Run a scan on a given device' \
'list:List all available devices' \
'download-ioc:Download the latest version of stalkerware-indicators ioc.yaml' \
'completions:Generate shell completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'spytrap-adb commands' commands "$@"
}
(( $+functions[_spytrap-adb__completions_commands] )) ||
_spytrap-adb__completions_commands() {
    local commands; commands=()
    _describe -t commands 'spytrap-adb completions commands' commands "$@"
}
(( $+functions[_spytrap-adb__download-ioc_commands] )) ||
_spytrap-adb__download-ioc_commands() {
    local commands; commands=()
    _describe -t commands 'spytrap-adb download-ioc commands' commands "$@"
}
(( $+functions[_spytrap-adb__help_commands] )) ||
_spytrap-adb__help_commands() {
    local commands; commands=(
'scan:Run a scan on a given device' \
'list:List all available devices' \
'download-ioc:Download the latest version of stalkerware-indicators ioc.yaml' \
'completions:Generate shell completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'spytrap-adb help commands' commands "$@"
}
(( $+functions[_spytrap-adb__help__completions_commands] )) ||
_spytrap-adb__help__completions_commands() {
    local commands; commands=()
    _describe -t commands 'spytrap-adb help completions commands' commands "$@"
}
(( $+functions[_spytrap-adb__help__download-ioc_commands] )) ||
_spytrap-adb__help__download-ioc_commands() {
    local commands; commands=()
    _describe -t commands 'spytrap-adb help download-ioc commands' commands "$@"
}
(( $+functions[_spytrap-adb__help__help_commands] )) ||
_spytrap-adb__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'spytrap-adb help help commands' commands "$@"
}
(( $+functions[_spytrap-adb__help__list_commands] )) ||
_spytrap-adb__help__list_commands() {
    local commands; commands=()
    _describe -t commands 'spytrap-adb help list commands' commands "$@"
}
(( $+functions[_spytrap-adb__help__scan_commands] )) ||
_spytrap-adb__help__scan_commands() {
    local commands; commands=()
    _describe -t commands 'spytrap-adb help scan commands' commands "$@"
}
(( $+functions[_spytrap-adb__list_commands] )) ||
_spytrap-adb__list_commands() {
    local commands; commands=()
    _describe -t commands 'spytrap-adb list commands' commands "$@"
}
(( $+functions[_spytrap-adb__scan_commands] )) ||
_spytrap-adb__scan_commands() {
    local commands; commands=()
    _describe -t commands 'spytrap-adb scan commands' commands "$@"
}

if [ "$funcstack[1]" = "_spytrap-adb" ]; then
    _spytrap-adb "$@"
else
    compdef _spytrap-adb spytrap-adb
fi
