File: mistral.bash_completion

package info (click to toggle)
python-mistralclient 1%3A2.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 888 kB
  • ctags: 1,301
  • sloc: python: 8,941; sh: 216; makefile: 26
file content (25 lines) | stat: -rw-r--r-- 784 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
_mistral_opts="" # lazy init
_mistral_flags="" # lazy init
_mistral_opts_exp="" # lazy init
_mistral()
{
	local cur prev mbc cflags
	COMPREPLY=()
	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"

	if [ "x$_mistral_opts" == "x" ] ; then
		mbc="`mistral bash-completion`"
		_mistral_opts="`echo "$mbc" | sed -e "s/\s-[a-z0-9_-]*//g" -e "s/\s\s*/ /g"`"
		_mistral_flags="`echo " $mbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/\s\s*/ /g"`"
		_mistral_opts_exp="`echo "$_mistral_opts" | sed -e "s/\s/|/g"`"
	fi

	if [[ " ${COMP_WORDS[@]} " =~ " "($_mistral_opts_exp)" " && "$prev" != "help" ]] ; then
		COMPREPLY=($(compgen -W "${_mistral_flags}" -- ${cur}))
	else
		COMPREPLY=($(compgen -W "${_mistral_opts}" -- ${cur}))
	fi
	return 0
}
complete -F _mistral mistral