# xkcdpass.bash-completion
# Part of Debian ‘xkcdpass’ package.
#
# Programmable Bash command completion for the ‘xkcdpass’ command.
# See the Bash manual “Programmable Completion” section.
#
# This is free software, and you are welcome to redistribute it under
# certain conditions; see the end of this file for copyright
# information, grant of license, and disclaimer of warranty.

_have xkcdpass &&
_xkcdpass_completion () {
    COMPREPLY=()

    local cur="${COMP_WORDS[COMP_CWORD]}"
    local prev="${COMP_WORDS[COMP_CWORD-1]}"

    local -a options=(
        -h --help -V --verbose
        -w --wordfile -v --valid-chars -a --acrostic
        -n --numwords --min --max
        -c --count -d --delimiter
    )

    case "${prev}" in
        -w|--wordfile)
            readarray -t COMPREPLY < <( compgen -G "${cur}*" )
            compopt -o filenames
            compopt -o plusdirs
            ;;
        -v|--valid-chars)
            # We have no useful completion for a literal regex argument.
            ;;
        -n|--numwords|--min|--max)
            # We have no useful completion for a numeric argument.
            ;;
        -c|--count)
            # We have no useful completion for a numeric argument.
            ;;
        *)
            readarray -t COMPREPLY < <( compgen -W "${options[*]}" -- "$cur" )
            ;;
    esac

    return 0

} && complete -F _xkcdpass_completion xkcdpass


# Copyright © 2015–2022 Ben Finney <bignose@debian.org>
#
# This is free software: you may copy, modify, and/or distribute this work
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 3 of that license or any later version.
# No warranty expressed or implied. See the file ‘LICENSE.GPL-3’ for details.

# Local variables:
# coding: utf-8
# mode: shell-script
# End:
# vim: fileencoding=utf-8 filetype=bash :
