]>
Commit | Line | Data |
---|---|---|
db456cd0 WG |
1 | #compdef hostnamectl |
2 | ||
3 | _hosts_or_user_at_host() { | |
4 | _alternative \ | |
5 | 'users-hosts:: _user_at_host' \ | |
6 | 'hosts:: _hosts' | |
7 | } | |
8 | ||
9 | _hostnamectl_command() { | |
10 | local -a _hostnamectl_cmds | |
11 | _hostnamectl_cmds=( | |
12 | "status:Show current hostname settings" | |
13 | "set-hostname:Set system hostname" | |
14 | "set-icon-name:Set icon name for host" | |
15 | ) | |
16 | if (( CURRENT == 1 )); then | |
17 | _describe -t commands 'hostnamectl commands' _hostnamectl_cmds || compadd "$@" | |
18 | else | |
19 | local curcontext="$curcontext" | |
20 | cmd="${${_hostnamectl_cmds[(r)$words[1]:*]%%:*}}" | |
21 | if (( $#cmd )); then | |
22 | [[ $cmd == status ]] && msg="no options" || msg="options for $cmd" | |
23 | _message "$msg" | |
24 | else | |
25 | _message "unknown hostnamectl command: $words[1]" | |
26 | fi | |
27 | fi | |
28 | } | |
29 | ||
30 | _arguments -s \ | |
31 | {-h,--help}'[Show this help]' \ | |
32 | '--version[Show package version]' \ | |
33 | '--transient[Only set transient hostname]' \ | |
34 | '--static[Only set static hostname]' \ | |
35 | '--pretty[Only set pretty hostname]' \ | |
36 | '--no-ask-password[Do not prompt for password]' \ | |
37 | {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \ | |
38 | '*::hostnamectl commands:_hostnamectl_command' |