File: boltctl

package info (click to toggle)
bolt 0.9.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,844 kB
  • sloc: ansic: 29,085; python: 2,938; xml: 460; javascript: 269; sh: 166; makefile: 14
file content (64 lines) | stat: -rw-r--r-- 1,025 bytes parent folder | download | duplicates (2)
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
61
62
63
64
_bolt_cmd_list=(
	'authorize'
	'config'
	'domains'
	'enroll'
	'forget'
	'info'
	'list'
	'monitor'
	'power'
)

_show_device()
{
	local devices
	devices=`boltctl list -a|grep uuid|awk {'print $3'}`
	COMPREPLY+=( $(compgen -W "${devices[@]}" -- "$cur") )
}

_show_config()
{
	local configs
	configs=`boltctl config --describe domain|awk {'print $2'}`
	configs+=`boltctl config --describe global|awk {'print $2'}`
	COMPREPLY+=( $(compgen -W "${configs[@]}" -- "$cur") )
}

_boltctl()
{
	local cur prev command arg args
	COMPREPLY=()
	_get_comp_words_by_ref cur prev
	_get_first_arg
	_count_args

	case $prev in
	-d|--describe)
		_show_device
		COMPREPLY+=( $(compgen -W "global domain" -- "$cur") )
		return 0
		;;
	esac

	case $arg in
	info|enroll|forget|authorize)
		_show_device
		;;

	config)
		COMPREPLY+=( $(compgen -W "--describe" -- "$cur") )
		_show_config
		;;

	*)
		if [[ "$args" = "1" ]]; then
			COMPREPLY=( $(compgen -W '${_bolt_cmd_list[@]}' -- "$cur") )
		fi
		;;
	esac

	return 0
}

complete -F _boltctl boltctl