summaryrefslogtreecommitdiffstats
path: root/tools/bcfg2-completion.bash
blob: b9e799cf855905a7be6437a4a9665231f2c3563e (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
# TODO: Add completion for each admin mode
_bcfg2-admin() {
	local cur prev possibles
	COMPREPLY=()
	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"

	if [[ ${COMP_CWORD} -eq 1 ]] || [[ -n "${prev}" && ${prev} == -* ]]
	then
		possibles="$(bcfg2-admin help | awk '{print $1}')"
	#elif bcfg2-admin ${prev} help &>/dev/null ; then
	#	possibles=$(bcfg2-admin ${prev} help | ${sedcmd})
	fi

	[[ -n "${possibles}" ]] && \
		COMPREPLY=( $(compgen -W "${possibles}" -- ${cur}) )

	return 0
}
_bcfg2-info() {
	local cur prev possibles
	COMPREPLY=()
	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"

	if [[ ${COMP_CWORD} -eq 1 ]] || [[ -n "${prev}" && ${prev} == -* ]]
	then
		possibles="$(bcfg2-info help | awk '{print $1}')"
	fi

	[[ -n "${possibles}" ]] && \
		COMPREPLY=( $(compgen -W "${possibles}" -- ${cur}) )

	return 0
}
complete -F _bcfg2-admin bcfg2-admin
complete -F _bcfg2-info bcfg2-info