shell-completion: support --json option for hostnamectl

This commit is contained in:
Yu Watanabe
2021-05-14 09:18:29 +09:00
parent bfc2b05e59
commit f8cd3f610f
2 changed files with 37 additions and 2 deletions
+8
View File
@@ -75,6 +75,13 @@ _hostnamectl_commands() {
fi
}
(( $+functions[_hostnamectl_get_json] )) || _hostnamectl_get_json()
{
local -a _json_forms
_json_forms=( $(hostnamectl --json=help 2>/dev/null) )
_values 'format' $_json_forms
}
_arguments -s \
{-h,--help}'[Show this help]' \
'--version[Show package version]' \
@@ -84,4 +91,5 @@ _arguments -s \
'--no-ask-password[Do not prompt for password]' \
{-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
{-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \
'--json[Shows output formatted as JSON]:format:_hostnamectl_get_json' \
'*::hostnamectl commands:_hostnamectl_commands'