From 7eb1f731eaf65b28e1bc80d26087bf44bdbe62be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 11 Jul 2014 08:25:20 -0400 Subject: [PATCH] shell-completion,man: beef up chassis completions and description Parameters to hostnamectl command are not optional and should not be marked as such in the man page. (cherry picked from commit 1ed774956406941d4812a3fb4493d2915f130f12) (cherry picked from commit ba838f7f9b3de1777f3528c0fe211f9bedbd2a8b) --- man/hostnamectl.xml | 73 +++++++++++++++++-------------- shell-completion/bash/hostnamectl | 3 ++ shell-completion/zsh/_hostnamectl | 32 +++++++++++++- shell-completion/zsh/_localectl | 4 +- 4 files changed, 75 insertions(+), 37 deletions(-) diff --git a/man/hostnamectl.xml b/man/hostnamectl.xml index f3038b325..b4aa43d36 100644 --- a/man/hostnamectl.xml +++ b/man/hostnamectl.xml @@ -172,13 +172,14 @@ - set-hostname [NAME] + set-hostname NAME Set the system - hostname. By default, this will alter - the pretty, the static, and the - transient hostname alike; however, if - one or more of + hostname to + NAME. By + default, this will alter the pretty, + the static, and the transient hostname + alike; however, if one or more of , , are used, @@ -199,55 +200,61 @@ the hostname string is not done if only the transient and/or static host names are set, and the pretty host - name is left untouched. Pass the empty - string as the - hostname to reset the selected - hostnames to their default (usually + name is left untouched. + + Pass the empty string + as the hostname to + reset the selected hostnames to their + default (usually localhost). - set-icon-name [NAME] + set-icon-name NAME Set the system icon - name. The icon name is used by some - graphical applications to visualize - this host. The icon name should follow - the NAME. The + icon name is used by some graphical + applications to visualize this host. + The icon name should follow the Icon - Naming Specification. Pass an - empty string to this operation to - reset the icon name to the default - value, which is determined from chassis - type (see below) and possibly other + Naming Specification. + + Pass an empty string to reset + the icon name to the default value, + which is determined from chassis type + (see below) and possibly other parameters. - set-chassis [TYPE] + set-chassis TYPE - Set the chassis - type. The chassis type is used by some + Set the chassis type + to TYPE. + The chassis type is used by some graphical applications to visualize - the host or alter user - interaction. Currently, the following - chassis types are defined: + the host or alter user interaction. + Currently, the following chassis types + are defined: desktop, laptop, server, tablet, - handset, - watch, as well as + handset, + watch, as well as the special chassis types vm and container for virtualized systems that lack an - immediate physical chassis. Pass an - empty string to this operation to - reset the chassis type to the default - value which is determined from the - firmware and possibly other - parameters. + immediate physical chassis. + + Pass an empty string to reset + the chassis type to the default value + which is determined from the firmware + and possibly other parameters. + diff --git a/shell-completion/bash/hostnamectl b/shell-completion/bash/hostnamectl index 9c75da9e7..22f8f06b6 100644 --- a/shell-completion/bash/hostnamectl +++ b/shell-completion/bash/hostnamectl @@ -39,6 +39,7 @@ _hostnamectl() { [STANDALONE]='status' [ICONS]='set-icon-name' [NAME]='set-hostname' + [CHASSIS]='set-chassis' ) for ((i=0; i < COMP_CWORD; i++)); do @@ -50,6 +51,8 @@ _hostnamectl() { if [[ -z $verb ]]; then comps=${VERBS[*]} + elif __contains_word "$verb" ${VERBS[CHASSIS]}; then + comps='desktop laptop server tablet handset watch vm container' elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[ICONS]} ${VERBS[NAME]}; then comps='' fi diff --git a/shell-completion/zsh/_hostnamectl b/shell-completion/zsh/_hostnamectl index 45b959789..52945d8f2 100644 --- a/shell-completion/zsh/_hostnamectl +++ b/shell-completion/zsh/_hostnamectl @@ -1,5 +1,30 @@ #compdef hostnamectl +_hostnamectl_set-hostname() { + if (( CURRENT <= 3 )); then + _message "new hostname" + else + _message "no more options" + fi +} + +_hostnamectl_set-icon-name() { + if (( CURRENT <= 3 )); then + _message "new icon name" + else + _message "no more options" + fi +} + +_hostnamectl_set-chassis() { + if (( CURRENT <= 3 )); then + _chassis=( desktop laptop server tablet handset watch vm container ) + _describe chassis _chassis + else + _message "no more options" + fi +} + _hostnamectl_command() { local -a _hostnamectl_cmds _hostnamectl_cmds=( @@ -13,8 +38,11 @@ _hostnamectl_command() { local curcontext="$curcontext" cmd="${${_hostnamectl_cmds[(r)$words[1]:*]%%:*}}" if (( $#cmd )); then - [[ $cmd == status ]] && msg="no options" || msg="options for $cmd" - _message "$msg" + if [[ $cmd == status ]]; then + _message "no options" + else + _hostnamectl_$cmd + fi else _message "unknown hostnamectl command: $words[1]" fi diff --git a/shell-completion/zsh/_localectl b/shell-completion/zsh/_localectl index c04f4f310..7756eb965 100644 --- a/shell-completion/zsh/_localectl +++ b/shell-completion/zsh/_localectl @@ -22,8 +22,8 @@ _localectl_set-locale() { _localectl_set-keymap() { local -a _keymaps - _keymaps=( ${(f)"$(_call_program locales "$service" list-keymaps)"} ) if (( CURRENT <= 3 )); then + _keymaps=( ${(f)"$(_call_program locales "$service" list-keymaps)"} ) _describe keymaps _keymaps else _message "no more options" @@ -73,7 +73,7 @@ _localectl_command() { if (( $+functions[_localectl_$cmd] )); then _localectl_$cmd else - _message "no more options" + _message "unknown localectl command: $words[1]" fi fi }