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