#compdef flawz

autoload -U is-at-least

_flawz() {
    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[@]}" : \
'*-f+[Feeds to sync. Accepts a year (\`2026\`), a year range (\`2002\:2026\`), \`recent\` (last 8 days of new publications) or \`modified\` (last 8 days of modifications). Multiple feeds can be given]::FEEDS:_default' \
'*--feeds=[Feeds to sync. Accepts a year (\`2026\`), a year range (\`2002\:2026\`), \`recent\` (last 8 days of new publications) or \`modified\` (last 8 days of modifications). Multiple feeds can be given]::FEEDS:_default' \
'-d+[Path to the SQLite database used to store the synced CVE data]:DB:_default' \
'--db=[Path to the SQLite database used to store the synced CVE data]:DB:_default' \
'-k+[NVD API key. With a key the rate limit is 50 requests / 30s (instead of 5 / 30s), making sync roughly 10× faster. Get one at <https\://nvd.nist.gov/developers/request-an-api-key>]:API_KEY:_default' \
'--api-key=[NVD API key. With a key the rate limit is 50 requests / 30s (instead of 5 / 30s), making sync roughly 10× faster. Get one at <https\://nvd.nist.gov/developers/request-an-api-key>]:API_KEY:_default' \
'-q+[Start with a search query]:QUERY:_default' \
'--query=[Start with a search query]:QUERY:_default' \
'-t+[Set the theme]:THEME:((dracula\:"Dracula"
nord\:"Nord"
one-dark\:"One Dark"
solarized-dark\:"Solarized Dark"
gruvbox-light\:"Gruvbox Light"
gruvbox-material-dark-hard\:"Gruvbox Material Dark Hard"
catppuccin\:"Catppuccin"))' \
'--theme=[Set the theme]:THEME:((dracula\:"Dracula"
nord\:"Nord"
one-dark\:"One Dark"
solarized-dark\:"Solarized Dark"
gruvbox-light\:"Gruvbox Light"
gruvbox-material-dark-hard\:"Gruvbox Material Dark Hard"
catppuccin\:"Catppuccin"))' \
'-u[Re-sync feeds that are already present in the cache]' \
'--force-update[Re-sync feeds that are already present in the cache]' \
'-o[Do not fetch feeds — read only what is already cached]' \
'--offline[Do not fetch feeds — read only what is already cached]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_flawz" ]; then
    _flawz "$@"
else
    compdef _flawz flawz
fi
