]>
Commit | Line | Data |
---|---|---|
db456cd0 | 1 | #compdef hostnamectl |
7059062c | 2 | # SPDX-License-Identifier: LGPL-2.1+ |
db456cd0 | 3 | |
1ed77495 ZJS |
4 | _hostnamectl_set-hostname() { |
5 | if (( CURRENT <= 3 )); then | |
6 | _message "new hostname" | |
7 | else | |
8 | _message "no more options" | |
9 | fi | |
10 | } | |
11 | ||
12 | _hostnamectl_set-icon-name() { | |
13 | if (( CURRENT <= 3 )); then | |
14 | _message "new icon name" | |
15 | else | |
16 | _message "no more options" | |
17 | fi | |
18 | } | |
19 | ||
20 | _hostnamectl_set-chassis() { | |
21 | if (( CURRENT <= 3 )); then | |
34b52450 | 22 | _chassis=( desktop laptop convertible server tablet handset watch embedded vm container ) |
1ed77495 ZJS |
23 | _describe chassis _chassis |
24 | else | |
25 | _message "no more options" | |
26 | fi | |
27 | } | |
28 | ||
ccb03ac3 ZJS |
29 | _hostnamectl_set-deployment() { |
30 | if (( CURRENT <= 3 )); then | |
31 | _message "new environment" | |
32 | else | |
33 | _message "no more options" | |
34 | fi | |
35 | } | |
36 | ||
d67b1f52 RC |
37 | _hostnamectl_set-location() { |
38 | if (( CURRENT <= 3 )); then | |
39 | _message "new location" | |
40 | else | |
41 | _message "no more options" | |
42 | fi | |
43 | } | |
44 | ||
db456cd0 WG |
45 | _hostnamectl_command() { |
46 | local -a _hostnamectl_cmds | |
47 | _hostnamectl_cmds=( | |
48 | "status:Show current hostname settings" | |
49 | "set-hostname:Set system hostname" | |
50 | "set-icon-name:Set icon name for host" | |
4433c995 | 51 | "set-chassis:Set chassis type for host" |
d67b1f52 RC |
52 | "set-deployment:Set deployment environment for host" |
53 | "set-location:Set location for host" | |
db456cd0 WG |
54 | ) |
55 | if (( CURRENT == 1 )); then | |
56 | _describe -t commands 'hostnamectl commands' _hostnamectl_cmds || compadd "$@" | |
57 | else | |
58 | local curcontext="$curcontext" | |
59 | cmd="${${_hostnamectl_cmds[(r)$words[1]:*]%%:*}}" | |
60 | if (( $#cmd )); then | |
1ed77495 ZJS |
61 | if [[ $cmd == status ]]; then |
62 | _message "no options" | |
63 | else | |
64 | _hostnamectl_$cmd | |
65 | fi | |
db456cd0 WG |
66 | else |
67 | _message "unknown hostnamectl command: $words[1]" | |
68 | fi | |
69 | fi | |
70 | } | |
71 | ||
72 | _arguments -s \ | |
73 | {-h,--help}'[Show this help]' \ | |
74 | '--version[Show package version]' \ | |
75 | '--transient[Only set transient hostname]' \ | |
76 | '--static[Only set static hostname]' \ | |
77 | '--pretty[Only set pretty hostname]' \ | |
78 | '--no-ask-password[Do not prompt for password]' \ | |
862f4963 | 79 | {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \ |
d67b1f52 | 80 | {-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \ |
db456cd0 | 81 | '*::hostnamectl commands:_hostnamectl_command' |