| 1 |
#compdef systemd-id128 |
| 2 |
|
| 3 |
local context state state_descr line |
| 4 |
typeset -A opt_args |
| 5 |
local expl |
| 6 |
|
| 7 |
local -a opt_common=( |
| 8 |
{-h,--help}'[show a help message and exit]' |
| 9 |
'--no-pager[do not pipe output into a pager]' |
| 10 |
'--no-legend[do not show the headers and footers]' |
| 11 |
'(-j)--json=[output inspection data in json format]:json-mode:(pretty short off)' |
| 12 |
'(--json)-j[equivalent to --json=short or --json=pretty on TTY]' |
| 13 |
'-p[generate samples of program code]' |
| 14 |
'(-P --value)'{-P,--value}'[only print the value]' |
| 15 |
'(-a --app-specific)'{-a+,--app-specific=}'[generate app-specific IDs]' |
| 16 |
'(-u --uuid)'{-u,--uuid}'[output in uuid format]' |
| 17 |
) |
| 18 |
|
| 19 |
local -a id128_commands=( |
| 20 |
'new:generate a new id' |
| 21 |
'machine-id:print the id of the current machine' |
| 22 |
'boot-id:print the id of the current boot' |
| 23 |
'invocation-id:print the id of the current invocation' |
| 24 |
'var-partition-uuid:print the uuid of the /var partition' |
| 25 |
'show:print one or more uuids' |
| 26 |
) |
| 27 |
|
| 28 |
_systemd-id128_names() { |
| 29 |
local expl |
| 30 |
local -a names=( ${${(@f)"$(_call_program -l id128-name systemd-id128 show)"}%% *} ) |
| 31 |
_wanted id128-name expl "name" compadd "$@" -a - names |
| 32 |
} |
| 33 |
|
| 34 |
local ret=1 |
| 35 |
_arguments -s -A '-*' "$opt_common[@]" \ |
| 36 |
':command:->command' \ |
| 37 |
'*:: :->option-or-argument' && ret=0 |
| 38 |
|
| 39 |
case $state in |
| 40 |
command) |
| 41 |
_describe -t command 'id128 command' id128_commands && ret=0 |
| 42 |
;; |
| 43 |
option-or-argument) |
| 44 |
local curcontext=${curcontext%:*:*}:systemd-id128-$words[1]: |
| 45 |
case $words[1] in |
| 46 |
*-id) |
| 47 |
_arguments -s "$opt_common[@]" && ret=0 |
| 48 |
;; |
| 49 |
show) |
| 50 |
_arguments -s "$opt_common[@]" ':name:_systemd-id128_names' && ret=0 |
| 51 |
;; |
| 52 |
esac |
| 53 |
;; |
| 54 |
esac |
| 55 |
return ret |