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