File: buildbot.bash-completion

package info (click to toggle)
buildbot 2.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 20,148 kB
  • sloc: python: 142,328; javascript: 10,508; sh: 1,013; makefile: 326
file content (60 lines) | stat: -rw-r--r-- 1,378 bytes parent folder | download | duplicates (5)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#
# This file installs BASH completions for 'buildbot' command.
#

_buildbot()
{
	local buildbot_subcommands="
	create-master upgrade-master start stop restart reconfig sighup user
	sendchange try tryserver checkconfig"

	local cur=${COMP_WORDS[COMP_CWORD]}
	local subcommand=
	local subcommand_args=
	local i=1

	#
	# 'parse' the command line so far
	# figure out if we have subcommand specified and any arguments to it
	#

	# skip global options
	while [[ "${COMP_WORDS[$i]}" == -* ]];
	do
		i=$(($i+1))
	done

	# save subcommand
	subcommand=${COMP_WORDS[$i]}
	i=$(($i+1))

	# skip subcommand options
	while [[ "${COMP_WORDS[$i]}" == -* ]];
	do
		i=$(($i+1))
	done

	# save subcommand arguments
	subcommand_args=${COMP_WORDS[@]:$i:${#COMP_WORDS[@]}}

	if [ "$cur" == "$subcommand" ]; then
		# suggest buildbot subcommands
		COMPREPLY=( $(compgen -W "$buildbot_subcommands" $cur) )
	elif [ "$cur" == "$subcommand_args" ]; then
		# we are at first subcommand argument
		case $subcommand in
		# these command take base directory as first argument,
		# suggest directories
		upgrade-master|create-master|start|stop|restart|reconfig|sighup)
			COMPREPLY=( $(compgen -A directory $cur) )
			;;
		# checkconfig takes a filename or directory as first argument
		checkconfig)
			COMPREPLY=( $(compgen -A file $cur) )
			;;
		esac
	fi
}

complete -F _buildbot buildbot
# ex: ft=sh noet