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