File: _systemd-id128

package info (click to toggle)
systemd-udeb 260-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 114,360 kB
  • sloc: ansic: 741,727; xml: 122,306; python: 35,714; sh: 35,154; cpp: 947; awk: 126; makefile: 89; lisp: 13; sed: 1
file content (55 lines) | stat: -rw-r--r-- 1,594 bytes parent folder | download | duplicates (4)
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
#compdef systemd-id128

local context state state_descr line
typeset -A opt_args
local expl

local -a opt_common=(
	{-h,--help}'[show a help message and exit]'
	'--no-pager[do not pipe output into a pager]'
	'--no-legend[do not show the headers and footers]'
	'(-j)--json=[output inspection data in json format]:json-mode:(pretty short off)'
	'(--json)-j[equivalent to --json=short or --json=pretty on TTY]'
	'-p[generate samples of program code]'
	'(-P --value)'{-P,--value}'[only print the value]'
	'(-a --app-specific)'{-a+,--app-specific=}'[generate app-specific IDs]'
	'(-u --uuid)'{-u,--uuid}'[output in uuid format]'
)

local -a id128_commands=(
	'new:generate a new id'
	'machine-id:print the id of the current machine'
	'boot-id:print the id of the current boot'
	'invocation-id:print the id of the current invocation'
	'var-partition-uuid:print the uuid of the /var partition'
	'show:print one or more uuids'
)

_systemd-id128_names() {
	local expl
	local -a names=( ${${(@f)"$(_call_program -l id128-name systemd-id128 show)"}%% *} )
	_wanted id128-name expl "name" compadd "$@" -a - names
}

local ret=1
_arguments -s -A '-*' "$opt_common[@]" \
	':command:->command' \
	'*:: :->option-or-argument' && ret=0

case $state in
	command)
		_describe -t command 'id128 command' id128_commands && ret=0
		;;
	option-or-argument)
		local curcontext=${curcontext%:*:*}:systemd-id128-$words[1]:
		case $words[1] in
			*-id)
				_arguments -s "$opt_common[@]" && ret=0
				;;
			show)
				_arguments -s "$opt_common[@]" ':name:_systemd-id128_names' && ret=0
				;;
		esac
		;;
esac
return ret