]>
Commit | Line | Data |
---|---|---|
20c8382b WG |
1 | #compdef timedatectl |
2 | ||
3 | _timedatectl_set-timezone(){ | |
4 | local -a _timezones | |
5 | _timezones=( ${(f)"$(_call_program timezones "${service}" list-timezones)"} ) | |
6 | compadd "$_timezones[@]" | |
7 | } | |
8 | ||
9 | _timedatectl_set-time(){ | |
10 | _message "YYYY-MM-DD HH:MM:SS" | |
11 | } | |
12 | ||
13 | _timedatectl_set-local-rtc(){ | |
14 | local -a _options | |
15 | _options=( | |
16 | '0:Maintain RTC in universal time' | |
17 | '1:Maintain RTC in local time' | |
18 | ) | |
19 | _describe options _options | |
20 | } | |
21 | ||
22 | _timedatectl_set-ntp(){ | |
23 | local -a _options | |
24 | _options=( | |
25 | '0:Disable NTP based network time configuration' | |
26 | '1:Enable NTP based network time configuration' | |
27 | ) | |
28 | _describe options _options | |
29 | } | |
30 | ||
31 | _timedatectl_command(){ | |
32 | local -a _timedatectl_cmds | |
33 | _timedatectl_cmds=( | |
34 | 'status:Show current time settings' | |
35 | 'set-time:Set system time' | |
36 | 'set-timezone:Set system timezone' | |
37 | 'list-timezones:Show known timezones' | |
38 | 'set-local-rtc:Control whether RTC is in local time' | |
39 | 'set-ntp:Control whether NTP is enabled' | |
40 | ) | |
41 | if (( CURRENT == 1 )); then | |
42 | _describe -t commands 'timedatectl command' _timedatectl_cmds | |
43 | else | |
44 | local curcontext="$curcontext" | |
45 | cmd="${${_timedatectl_cmds[(r)$words[1]:*]%%:*}}" | |
46 | if (( $#cmd )); then | |
47 | if (( $+functions[_timedatectl_$cmd] )); then | |
48 | _timedatectl_$cmd | |
49 | else | |
50 | _message "no more options" | |
51 | fi | |
52 | else | |
53 | _message "unknown timedatectl command: $words[1]" | |
54 | fi | |
55 | fi | |
56 | } | |
57 | ||
20c8382b WG |
58 | _arguments -s \ |
59 | {-h,--help}'[Show this help]' \ | |
60 | '--version[Show package version]' \ | |
61 | '--adjust-system-clock[Adjust system clock when changing local RTC mode]' \ | |
62 | '--no-pager[Do not pipe output into a pager]' \ | |
63 | '--no-ask-password[Do not prompt for password]' \ | |
862f4963 | 64 | {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \ |
20c8382b | 65 | '*::timedatectl commands:_timedatectl_command' |