_hostnamectl revision db456cd0c65d0e7375b09b72ae6fb60f09e2eb6e
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas#compdef hostnamectl
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas_hosts_or_user_at_host() {
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas _alternative \
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas 'users-hosts:: _user_at_host' \
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas 'hosts:: _hosts'
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas}
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas
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"
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
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas [[ $cmd == status ]] && msg="no options" || msg="options for $cmd"
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas _message "$msg"
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]' \
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
db456cd0c65d0e7375b09b72ae6fb60f09e2eb6eWilliam Giokas '*::hostnamectl commands:_hostnamectl_command'