db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas#compdef hostnamectl
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek_hostnamectl_set-hostname() {
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek if (( CURRENT <= 3 )); then
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek _message "new hostname"
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek else
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek _message "no more options"
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek fi
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek}
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek_hostnamectl_set-icon-name() {
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek if (( CURRENT <= 3 )); then
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek _message "new icon name"
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek else
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek _message "no more options"
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek fi
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek}
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek_hostnamectl_set-chassis() {
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek if (( CURRENT <= 3 )); then
25fa306ed58b0b7fe30ca9be37c66a7b3b2de70eLennart Poettering _chassis=( desktop laptop server tablet handset watch embedded vm container )
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek _describe chassis _chassis
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek else
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek _message "no more options"
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek fi
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek}
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek
ccb03ac39d5360433e62b8b82e474aa044421bd9Zbigniew Jędrzejewski-Szmek_hostnamectl_set-deployment() {
ccb03ac39d5360433e62b8b82e474aa044421bd9Zbigniew Jędrzejewski-Szmek if (( CURRENT <= 3 )); then
ccb03ac39d5360433e62b8b82e474aa044421bd9Zbigniew Jędrzejewski-Szmek _message "new environment"
ccb03ac39d5360433e62b8b82e474aa044421bd9Zbigniew Jędrzejewski-Szmek else
ccb03ac39d5360433e62b8b82e474aa044421bd9Zbigniew Jędrzejewski-Szmek _message "no more options"
ccb03ac39d5360433e62b8b82e474aa044421bd9Zbigniew Jędrzejewski-Szmek fi
ccb03ac39d5360433e62b8b82e474aa044421bd9Zbigniew Jędrzejewski-Szmek}
ccb03ac39d5360433e62b8b82e474aa044421bd9Zbigniew Jędrzejewski-Szmek
d67b1f525f488e5dfc076972cccf2a6411257fb8Ronny Chevalier_hostnamectl_set-location() {
d67b1f525f488e5dfc076972cccf2a6411257fb8Ronny Chevalier if (( CURRENT <= 3 )); then
d67b1f525f488e5dfc076972cccf2a6411257fb8Ronny Chevalier _message "new location"
d67b1f525f488e5dfc076972cccf2a6411257fb8Ronny Chevalier else
d67b1f525f488e5dfc076972cccf2a6411257fb8Ronny Chevalier _message "no more options"
d67b1f525f488e5dfc076972cccf2a6411257fb8Ronny Chevalier fi
d67b1f525f488e5dfc076972cccf2a6411257fb8Ronny Chevalier}
d67b1f525f488e5dfc076972cccf2a6411257fb8Ronny Chevalier
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas_hostnamectl_command() {
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas local -a _hostnamectl_cmds
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas _hostnamectl_cmds=(
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas "status:Show current hostname settings"
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas "set-hostname:Set system hostname"
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas "set-icon-name:Set icon name for host"
4433c995c77b66f42fe4a238aff6b53706628a2eDaniel Mack "set-chassis:Set chassis type for host"
d67b1f525f488e5dfc076972cccf2a6411257fb8Ronny Chevalier "set-deployment:Set deployment environment for host"
d67b1f525f488e5dfc076972cccf2a6411257fb8Ronny Chevalier "set-location:Set location for host"
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas )
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas if (( CURRENT == 1 )); then
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas _describe -t commands 'hostnamectl commands' _hostnamectl_cmds || compadd "$@"
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas else
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas local curcontext="$curcontext"
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas cmd="${${_hostnamectl_cmds[(r)$words[1]:*]%%:*}}"
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas if (( $#cmd )); then
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek if [[ $cmd == status ]]; then
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek _message "no options"
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek else
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek _hostnamectl_$cmd
1ed774956406941d4812a3fb4493d2915f130f12Zbigniew Jędrzejewski-Szmek fi
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas else
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas _message "unknown hostnamectl command: $words[1]"
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas fi
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas fi
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas}
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas_arguments -s \
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas {-h,--help}'[Show this help]' \
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas '--version[Show package version]' \
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas '--transient[Only set transient hostname]' \
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas '--static[Only set static hostname]' \
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas '--pretty[Only set pretty hostname]' \
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas '--no-ask-password[Do not prompt for password]' \
862f4963c6f7778cea9e715eeb11ea959eba6db3William Giokas {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
d67b1f525f488e5dfc076972cccf2a6411257fb8Ronny Chevalier {-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas '*::hostnamectl commands:_hostnamectl_command'