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