_noir_completions() {
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="
        -b --base-path
        -u --url
        -f --format
        -o --output
        --set-pvalue
        --set-pvalue-header
        --set-pvalue-cookie
        --set-pvalue-query
        --set-pvalue-form
        --set-pvalue-json
        --set-pvalue-path
        --status-codes
        --exclude-codes
        --include-path
        --include-techs
        --no-color
        --no-log
        -P --passive-scan
        --passive-scan-path
        --passive-scan-severity
        --passive-scan-auto-update
        --passive-scan-no-update-check
        -T --use-all-taggers
        --use-taggers
        --list-taggers
        --send-req
        --send-proxy
        --send-es
        --with-headers
        --use-matchers
        --use-filters
        --diff-path
        -t --techs
        --exclude-techs
        --only-techs
        --list-techs
        --config-file
        --concurrency
        --generate-completion
        --cache-disable
        --cache-clear
        --ai-provider
        --ai-model
        --ai-key
        --ai-max-token
        --ollama
        --ollama-model
        -d --debug
        -v --version
        --build-info
        --verbose
        --help-all
        -h --help
    "

    case "${prev}" in
        -f|--format)
            COMPREPLY=( $(compgen -W "plain yaml json jsonl toml markdown-table sarif html curl httpie powershell oas2 oas3 postman only-url only-param only-header only-cookie only-tag mermaid" -- "${cur}") )
            return 0
            ;;
        --send-proxy|--send-es|--with-headers|--use-matchers|--use-filters|--diff-path|--config-file|--set-pvalue|--techs|--exclude-techs|--only-techs|--ollama|--ollama-model|-o|-b|-u)
            COMPREPLY=( $(compgen -f -- "${cur}") )
            return 0
            ;;
        --generate-completion)
            COMPREPLY=( $(compgen -W "zsh bash fish" -- "${cur}") )
            return 0
            ;;
        --passive-scan-severity)
            COMPREPLY=( $(compgen -W "critical high medium low" -- "${cur}") )
            return 0
            ;;
        --ai-provider|--ai-model|--ai-key|--ai-max-token|--ollama|--ollama-model)
            COMPREPLY=( $(compgen -f -- "${cur}") )
            return 0
            ;;
        *)
            ;;
    esac

    COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
    return 0
}

complete -F _noir_completions noir
