# alfa(1) completion
# rw@nebulousresearch.org

_alfa()
{
    local cur prev opts words cword helium_options icf_options extinction_options verbosity_options
    _init_completion || return
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="-n --normalise -vg --velocity-guess -rg --resolution-guess -vtol1 --velocity-tolerance-1 -vtol2 --velocity-tolerance-2 -rtol1 --resolution-tolerance-1 -rtol2 --resolution-tolerance-2 -ss --subtract-sky -o --output-dir -skycat -strongcat -deepcat -g --generations -ps --populationsize -pr --pressure -b --bad-data -ul --upper-limits --citation"

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

    case "${prev}" in
        -deepcat|-strongcat|-skycat)
            _filedir
            return 0
            ;;
        -o|--output-dir)
            _filedir -d
            return 0
            ;;
        --pressure|-g|-ps|--generations|--resolution-guess|-n|--resolution-tolerance-1|--velocity-guess|--normalise|--resolution-tolerance-2|--velocity-tolerance-1|-rg|--velocity-tolerance-2|-rtol1|-vg|--populationsize|-rtol2|-vtol1|-pr|-vtol2|-b|--bad-data|-ul|--upper-limits|--citation)
            COMPREPLY=()
            return 0
            ;;
    esac

    _filedir '@(fit?(s)|ascii|dat|txt)'
}
complete -F _alfa alfa
