# Bash completion script for inventory-collector

_inventory_collector_completion() {
    local cur prev opts formats
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    opts="-o --output -f --format -s --source --check --dry-run --list --sync -q --quiet -v --verbose -c --config -t --tag --filter-tag -g --group --category --filter-group --source-type --filter-source --origin --sort --sort-by -r --reverse --ansible-dest --lc-dest -V --version -h --help"
    formats="ansible-yaml ansible-json linux-connector yaml xml ini"

    case "${prev}" in
        -f|--format)
            COMPREPLY=( $(compgen -W "${formats}" -- "${cur}") )
            return 0
            ;;
        --source-type|--filter-source|--origin)
            COMPREPLY=( $(compgen -W "proxmox static file plik k3s" -- "${cur}") )
            return 0
            ;;
        --sort|--sort-by)
            COMPREPLY=( $(compgen -W "name ip" -- "${cur}") )
            return 0
            ;;
        -o|--output|-s|--source|-c|--config|--ansible-dest|--lc-dest)
            COMPREPLY=( $(compgen -f -- "${cur}") )
            return 0
            ;;
    esac

    if [[ "${cur}" == -* ]]; then
        COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
        return 0
    fi
}

complete -F _inventory_collector_completion inventory-collector
