chiark / gitweb /
shell-completion,man: beef up chassis completions and description
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 11 Jul 2014 12:25:20 +0000 (08:25 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 11 Jul 2014 13:22:00 +0000 (09:22 -0400)
Parameters to hostnamectl command are not optional and should not be marked
as such in the man page.

man/hostnamectl.xml
shell-completion/bash/hostnamectl
shell-completion/zsh/_hostnamectl
shell-completion/zsh/_localectl

index eac304012e1ca2c1c9c39326e92f8d6ed5754dcc..a158e67519c322ccba35a7992cc57f77b5befd3e 100644 (file)
                         </varlistentry>
 
                         <varlistentry>
-                                <term><command>set-hostname [NAME]</command></term>
+                                <term><command>set-hostname <replaceable>NAME</replaceable></command></term>
 
                                 <listitem><para>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
+                                <replaceable>NAME</replaceable>. By
+                                default, this will alter the pretty,
+                                the static, and the transient hostname
+                                alike; however, if one or more of
                                 <option>--static</option>,
                                 <option>--transient</option>,
                                 <option>--pretty</option> are used,
                                 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 <literal></literal> as the
-                                hostname to reset the selected
-                                hostnames to their default (usually
+                                name is left untouched.</para>
+
+                                <para>Pass the empty string
+                                <literal></literal> as the hostname to
+                                reset the selected hostnames to their
+                                default (usually
                                 <literal>localhost</literal>).</para></listitem>
                         </varlistentry>
 
                         <varlistentry>
-                                <term><command>set-icon-name [NAME]</command></term>
+                                <term><command>set-icon-name <replaceable>NAME</replaceable></command></term>
 
                                 <listitem><para>Set the system icon
-                                name. The icon name is used by some
-                                graphical applications to visualize
-                                this host. The icon name should follow
-                                the <ulink
+                                name to
+                                <replaceable>NAME</replaceable>. The
+                                icon name is used by some graphical
+                                applications to visualize this host.
+                                The icon name should follow the <ulink
                                 url="http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html">Icon
-                                Naming Specification</ulink>. 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</ulink>.</para>
+
+                                <para>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.</para></listitem>
                         </varlistentry>
 
                         <varlistentry>
-                                <term><command>set-chassis [TYPE]</command></term>
+                                <term><command>set-chassis <replaceable>TYPE</replaceable></command></term>
 
-                                <listitem><para>Set the chassis
-                                type. The chassis type is used by some
+                                <listitem><para>Set the chassis type
+                                to <replaceable>TYPE</replaceable>.
+                                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:
                                 <literal>desktop</literal>,
                                 <literal>laptop</literal>,
                                 <literal>server</literal>,
                                 <literal>tablet</literal>,
-                               <literal>handset</literal>,
-                               <literal>watch</literal>, as well as
+                                <literal>handset</literal>,
+                                <literal>watch</literal>, as well as
                                 the special chassis types
                                 <literal>vm</literal> and
                                 <literal>container</literal> 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.</para></listitem>
+                                immediate physical chassis.</para>
+
+                                <para>Pass an empty string to reset
+                                the chassis type to the default value
+                                which is determined from the firmware
+                                and possibly other parameters.</para>
+                                </listitem>
                         </varlistentry>
 
                 </variablelist>
index 9c75da9e7f8b6f699f0d465d1563e9e10e514650..22f8f06b694349e418a0744b817f7706d7997826 100644 (file)
@@ -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
index 7effa0489ee8dabf29d3ca0d8f50f639b02ac03c..be8687609eb39f172c3b9067d56eb33ea6578027 100644 (file)
@@ -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=(
@@ -14,8 +39,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
index 87432da1dc97af5bd7909f176019ae4ded4879b0..d8af4d186374a100c7384e361bdf62c6f31cf381 100644 (file)
@@ -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"
@@ -77,7 +77,7 @@ _localectl_command() {
         if (( $+functions[_localectl_$cmd] )); then
             _localectl_$cmd
         else
-            _message "no more options"
+            _message "unknown localectl command: $words[1]"
         fi
     fi
 }