# -*- sh -*-
#
# Bash completion function for the 'trashtalk' command.

_trashtalk()
{
    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}

    #
    #  All known commands accepted.  Sorted.
    #
    #
    var=""
	for val in ${COMP_WORDS[@]}
	do
		var+=" "$val
	done
    opts=`python3 -c "from trashtalk import autocomplete; autocomplete('$var')"`
    #
    #
    #
    #
    if [ -z "$opts" ]
    then
	COMPREPLY=()
	_filedir
	return 0
    else
	local IFS=$'\n'
    	COMPREPLY=( $(compgen -W "${opts[*]}" -- ${cur}) )
    fi
    return 0

}
complete -F _trashtalk $filenames trashtalk
