#!/bin/bash

# env-backup-completion.bash - Bash completion for environment backup scripts
# Source this file or copy to ~/.local/share/bash-completion/completions/

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

    opts="--help --init --force --dry-run --restore --list --gitea-url --username"

    case ${prev} in
        --gitea-url|-g)
            # Suggest common gitea URL patterns
            COMPREPLY=( $(compgen -W "https://git. https://gitea. https://code." -- ${cur}) )
            return 0
            ;;
        --username|-u)
            # No completion for username
            return 0
            ;;
        *)
            ;;
    esac

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

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

    opts="--help --verbose --summary-only --missing-only --diff"

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

# Register completion functions
complete -F _backup_env_files backup-env-files.sh
complete -F _validate_env_backups validate-env-backups.sh

# Also register for the full path versions
complete -F _backup_env_files ./backup-env-files.sh
complete -F _validate_env_backups ./validate-env-backups.sh
