2019-04-05 09:41:35 +00:00
|
|
|
#compdef hostnamectl -*- shell-script -*-
|
2020-11-09 04:23:58 +00:00
|
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
2013-07-29 19:05:48 +00:00
|
|
|
|
2021-04-23 18:41:45 +00:00
|
|
|
(( $+functions[_hostnamectl_hostname] )) ||
|
|
|
|
_hostnamectl_hostname() {
|
2014-07-11 12:25:20 +00:00
|
|
|
if (( CURRENT <= 3 )); then
|
|
|
|
_message "new hostname"
|
|
|
|
else
|
|
|
|
_message "no more options"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-04-23 18:41:45 +00:00
|
|
|
(( $+functions[_hostnamectl_icon-name] )) ||
|
|
|
|
_hostnamectl_icon-name() {
|
2014-07-11 12:25:20 +00:00
|
|
|
if (( CURRENT <= 3 )); then
|
|
|
|
_message "new icon name"
|
|
|
|
else
|
|
|
|
_message "no more options"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-04-23 18:41:45 +00:00
|
|
|
(( $+functions[_hostnamectl_chassis] )) ||
|
|
|
|
_hostnamectl_chassis() {
|
2014-07-11 12:25:20 +00:00
|
|
|
if (( CURRENT <= 3 )); then
|
2017-02-28 10:54:52 +00:00
|
|
|
_chassis=( desktop laptop convertible server tablet handset watch embedded vm container )
|
2014-07-11 12:25:20 +00:00
|
|
|
_describe chassis _chassis
|
|
|
|
else
|
|
|
|
_message "no more options"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-04-23 18:41:45 +00:00
|
|
|
(( $+functions[_hostnamectl_deployment] )) ||
|
|
|
|
_hostnamectl_deployment() {
|
2014-07-11 13:08:47 +00:00
|
|
|
if (( CURRENT <= 3 )); then
|
|
|
|
_message "new environment"
|
|
|
|
else
|
|
|
|
_message "no more options"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-04-23 18:41:45 +00:00
|
|
|
(( $+functions[_hostnamectl_location] )) ||
|
|
|
|
_hostnamectl_location() {
|
2015-04-07 18:14:28 +00:00
|
|
|
if (( CURRENT <= 3 )); then
|
|
|
|
_message "new location"
|
|
|
|
else
|
|
|
|
_message "no more options"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-12-24 11:15:38 +00:00
|
|
|
(( $+functions[_hostnamectl_commands] )) ||
|
|
|
|
_hostnamectl_commands() {
|
2013-07-29 19:05:48 +00:00
|
|
|
local -a _hostnamectl_cmds
|
|
|
|
_hostnamectl_cmds=(
|
|
|
|
"status:Show current hostname settings"
|
2021-04-23 18:41:45 +00:00
|
|
|
"hostname:Get/set system hostname"
|
|
|
|
"icon-name:Get/set icon name for host"
|
|
|
|
"chassis:Get/set chassis type for host"
|
|
|
|
"deployment:Get/set deployment environment for host"
|
|
|
|
"location:Get/set location for host"
|
2013-07-29 19:05:48 +00:00
|
|
|
)
|
|
|
|
if (( CURRENT == 1 )); then
|
|
|
|
_describe -t commands 'hostnamectl commands' _hostnamectl_cmds || compadd "$@"
|
|
|
|
else
|
|
|
|
local curcontext="$curcontext"
|
|
|
|
cmd="${${_hostnamectl_cmds[(r)$words[1]:*]%%:*}}"
|
|
|
|
if (( $#cmd )); then
|
2014-07-11 12:25:20 +00:00
|
|
|
if [[ $cmd == status ]]; then
|
|
|
|
_message "no options"
|
|
|
|
else
|
|
|
|
_hostnamectl_$cmd
|
|
|
|
fi
|
2013-07-29 19:05:48 +00:00
|
|
|
else
|
|
|
|
_message "unknown hostnamectl command: $words[1]"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-05-12 16:37:41 +00:00
|
|
|
(( $+functions[_hostnamectl_get_json] )) || _hostnamectl_get_json()
|
|
|
|
{
|
|
|
|
local -a _json_forms
|
|
|
|
_json_forms=( $(hostnamectl --json=help 2>/dev/null) )
|
|
|
|
_values 'format' $_json_forms
|
|
|
|
}
|
|
|
|
|
2013-07-29 19:05:48 +00:00
|
|
|
_arguments -s \
|
|
|
|
{-h,--help}'[Show this help]' \
|
|
|
|
'--version[Show package version]' \
|
|
|
|
'--transient[Only set transient hostname]' \
|
|
|
|
'--static[Only set static hostname]' \
|
|
|
|
'--pretty[Only set pretty hostname]' \
|
|
|
|
'--no-ask-password[Do not prompt for password]' \
|
2013-08-21 03:06:54 +00:00
|
|
|
{-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
|
2015-04-07 18:14:28 +00:00
|
|
|
{-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \
|
2021-05-12 16:37:41 +00:00
|
|
|
'--json[Shows output formatted as JSON]:format:_hostnamectl_get_json' \
|
2018-12-24 11:15:38 +00:00
|
|
|
'*::hostnamectl commands:_hostnamectl_commands'
|