20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas#compdef timedatectl
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas_timedatectl_set-timezone(){
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas local -a _timezones
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas _timezones=( ${(f)"$(_call_program timezones "${service}" list-timezones)"} )
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas compadd "$_timezones[@]"
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas_timedatectl_set-time(){
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas _message "YYYY-MM-DD HH:MM:SS"
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas_timedatectl_set-local-rtc(){
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas local -a _options
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas '0:Maintain RTC in universal time'
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas '1:Maintain RTC in local time'
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas _describe options _options
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas_timedatectl_set-ntp(){
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas local -a _options
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas '0:Disable NTP based network time configuration'
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas '1:Enable NTP based network time configuration'
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas _describe options _options
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas_timedatectl_command(){
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas local -a _timedatectl_cmds
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas _timedatectl_cmds=(
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas 'status:Show current time settings'
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas 'set-time:Set system time'
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas 'set-timezone:Set system timezone'
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas 'list-timezones:Show known timezones'
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas 'set-local-rtc:Control whether RTC is in local time'
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas 'set-ntp:Control whether NTP is enabled'
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas if (( CURRENT == 1 )); then
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas _describe -t commands 'timedatectl command' _timedatectl_cmds
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas local curcontext="$curcontext"
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas cmd="${${_timedatectl_cmds[(r)$words[1]:*]%%:*}}"
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas if (( $#cmd )); then
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas if (( $+functions[_timedatectl_$cmd] )); then
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas _timedatectl_$cmd
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas _message "no more options"
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas _message "unknown timedatectl command: $words[1]"
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas_arguments -s \
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas {-h,--help}'[Show this help]' \
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas '--version[Show package version]' \
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas '--adjust-system-clock[Adjust system clock when changing local RTC mode]' \
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas '--no-pager[Do not pipe output into a pager]' \
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas '--no-ask-password[Do not prompt for password]' \
862f4963c6f7778cea9e715eeb11ea959eba6db3William Giokas {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
c285cb5c559638689e3d9e9894a81574ed69d560Ronny Chevalier {-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \
20c8382ba7c65be3aa2d141501cc934262f776baWilliam Giokas '*::timedatectl commands:_timedatectl_command'