]>
Commit | Line | Data |
---|---|---|
c1072f64 | 1 | #compdef hostnamectl -*- shell-script -*- |
7059062c | 2 | # SPDX-License-Identifier: LGPL-2.1+ |
db456cd0 | 3 | |
c501ecd7 | 4 | (( $+functions[_hostnamectl_set-hostname] )) || |
1ed77495 ZJS |
5 | _hostnamectl_set-hostname() { |
6 | if (( CURRENT <= 3 )); then | |
7 | _message "new hostname" | |
8 | else | |
9 | _message "no more options" | |
10 | fi | |
11 | } | |
12 | ||
c501ecd7 | 13 | (( $+functions[_hostnamectl_set-icon-name] )) || |
1ed77495 ZJS |
14 | _hostnamectl_set-icon-name() { |
15 | if (( CURRENT <= 3 )); then | |
16 | _message "new icon name" | |
17 | else | |
18 | _message "no more options" | |
19 | fi | |
20 | } | |
21 | ||
c501ecd7 | 22 | (( $+functions[_hostnamectl_set-chassis] )) || |
1ed77495 ZJS |
23 | _hostnamectl_set-chassis() { |
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 | ||
c501ecd7 | 32 | (( $+functions[_hostnamectl_set-deployment] )) || |
ccb03ac3 ZJS |
33 | _hostnamectl_set-deployment() { |
34 | if (( CURRENT <= 3 )); then | |
35 | _message "new environment" | |
36 | else | |
37 | _message "no more options" | |
38 | fi | |
39 | } | |
40 | ||
c501ecd7 | 41 | (( $+functions[_hostnamectl_set-location] )) || |
d67b1f52 RC |
42 | _hostnamectl_set-location() { |
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" | |
55 | "set-hostname:Set system hostname" | |
56 | "set-icon-name:Set icon name for host" | |
4433c995 | 57 | "set-chassis:Set chassis type for host" |
d67b1f52 RC |
58 | "set-deployment:Set deployment environment for host" |
59 | "set-location: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 | ||
78 | _arguments -s \ | |
79 | {-h,--help}'[Show this help]' \ | |
80 | '--version[Show package version]' \ | |
81 | '--transient[Only set transient hostname]' \ | |
82 | '--static[Only set static hostname]' \ | |
83 | '--pretty[Only set pretty hostname]' \ | |
84 | '--no-ask-password[Do not prompt for password]' \ | |
862f4963 | 85 | {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \ |
d67b1f52 | 86 | {-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \ |
c501ecd7 | 87 | '*::hostnamectl commands:_hostnamectl_commands' |