| 1 |
#compdef hostnamectl |
| 2 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
|
| 4 |
(( $+functions[_hostnamectl_hostname] )) || |
| 5 |
_hostnamectl_hostname() { |
| 6 |
if (( CURRENT <= 3 )); then |
| 7 |
_message "new hostname" |
| 8 |
else |
| 9 |
_message "no more options" |
| 10 |
fi |
| 11 |
} |
| 12 |
|
| 13 |
(( $+functions[_hostnamectl_icon-name] )) || |
| 14 |
_hostnamectl_icon-name() { |
| 15 |
if (( CURRENT <= 3 )); then |
| 16 |
_message "new icon name" |
| 17 |
else |
| 18 |
_message "no more options" |
| 19 |
fi |
| 20 |
} |
| 21 |
|
| 22 |
(( $+functions[_hostnamectl_chassis] )) || |
| 23 |
_hostnamectl_chassis() { |
| 24 |
if (( CURRENT <= 3 )); then |
| 25 |
_chassis=( desktop laptop convertible server tablet handset watch embedded vm container ) |
| 26 |
_describe chassis _chassis |
| 27 |
else |
| 28 |
_message "no more options" |
| 29 |
fi |
| 30 |
} |
| 31 |
|
| 32 |
(( $+functions[_hostnamectl_deployment] )) || |
| 33 |
_hostnamectl_deployment() { |
| 34 |
if (( CURRENT <= 3 )); then |
| 35 |
_message "new environment" |
| 36 |
else |
| 37 |
_message "no more options" |
| 38 |
fi |
| 39 |
} |
| 40 |
|
| 41 |
(( $+functions[_hostnamectl_location] )) || |
| 42 |
_hostnamectl_location() { |
| 43 |
if (( CURRENT <= 3 )); then |
| 44 |
_message "new location" |
| 45 |
else |
| 46 |
_message "no more options" |
| 47 |
fi |
| 48 |
} |
| 49 |
|
| 50 |
(( $+functions[_hostnamectl_tags] )) || |
| 51 |
_hostnamectl_tags() { |
| 52 |
_message "machine tag" |
| 53 |
} |
| 54 |
|
| 55 |
(( $+functions[_hostnamectl_commands] )) || |
| 56 |
_hostnamectl_commands() { |
| 57 |
local -a _hostnamectl_cmds |
| 58 |
_hostnamectl_cmds=( |
| 59 |
"status:Show current hostname settings" |
| 60 |
"hostname:Get/set system hostname" |
| 61 |
"icon-name:Get/set icon name for host" |
| 62 |
"chassis:Get/set chassis type for host" |
| 63 |
"deployment:Get/set deployment environment for host" |
| 64 |
"location:Get/set location for host" |
| 65 |
"tags:Get/set machine tags for host" |
| 66 |
) |
| 67 |
if (( CURRENT == 1 )); then |
| 68 |
_describe -t commands 'hostnamectl commands' _hostnamectl_cmds || compadd "$@" |
| 69 |
else |
| 70 |
local curcontext="$curcontext" |
| 71 |
cmd="${${_hostnamectl_cmds[(r)$words[1]:*]%%:*}}" |
| 72 |
if (( $#cmd )); then |
| 73 |
if [[ $cmd == status ]]; then |
| 74 |
_message "no options" |
| 75 |
else |
| 76 |
_hostnamectl_$cmd |
| 77 |
fi |
| 78 |
else |
| 79 |
_message "unknown hostnamectl command: $words[1]" |
| 80 |
fi |
| 81 |
fi |
| 82 |
} |
| 83 |
|
| 84 |
(( $+functions[_hostnamectl_get_json] )) || _hostnamectl_get_json() |
| 85 |
{ |
| 86 |
local -a _json_forms |
| 87 |
_json_forms=( $(hostnamectl --json=help 2>/dev/null) ) |
| 88 |
_values 'format' $_json_forms |
| 89 |
} |
| 90 |
|
| 91 |
_arguments -s \ |
| 92 |
'(- *)'{-h,--help}'[Show this help]' \ |
| 93 |
'(- *)--version[Show package version]' \ |
| 94 |
'--transient[Only set transient hostname]' \ |
| 95 |
'--static[Only set static hostname]' \ |
| 96 |
'--pretty[Only set pretty hostname]' \ |
| 97 |
'--no-ask-password[Do not prompt for password]' \ |
| 98 |
'(-H --host)'{-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \ |
| 99 |
'(-M --machine)'{-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \ |
| 100 |
'--json=[Shows output formatted as JSON]:format:_hostnamectl_get_json' \ |
| 101 |
'*::hostnamectl commands:_hostnamectl_commands' |