]> git.ipfire.org Git - people/ms/network.git/commitdiff
Move list-hooks command as sub-command of help
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 15 Sep 2016 20:50:33 +0000 (22:50 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 15 Sep 2016 20:50:33 +0000 (22:50 +0200)
Fixes #11181

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
man/network-zone.xml
man/network.xml
src/network

index acf4530d98e9bba28864146d9a952e6e9b64a804..cd7017a33e452dd653cebc7e3bd0f43bc6d1df9f 100644 (file)
                        <command>network zone <arg choice="plain">[new|destroy]</arg> <replaceable>ZONE</replaceable> ...</command>
                </cmdsynopsis>
 
-               <cmdsynopsis>
-                       <command>network zone <arg choice="plain">list-hooks</arg></command>
-               </cmdsynopsis>
-
                <cmdsynopsis>
                        <command>network zone <replaceable>ZONE</replaceable> <arg choice="plain">command</arg> ...</command>
                </cmdsynopsis>
                                        </para>
                                </listitem>
                        </varlistentry>
-
-                       <varlistentry>
-                               <term>
-                                       <command>list-hooks</command>
-                               </term>
-
-                               <listitem>
-                                       <para>
-                                               Outputs a list of all eligible hooks for the zones.
-                                       </para>
-                               </listitem>
-                       </varlistentry>
                </variablelist>
 
                <para>
index 90ab27cf0a9b069a05a4a1ce2549105c58ba6183..f40ad843d94c7c952fc8a010b12446ebf7244ddb 100644 (file)
 
                        <varlistentry>
                                <term>
-                                       <command>help [<replaceable>TYPE</replaceable> <replaceable>HOOK</replaceable>]</command>
+                                       <command>help [<replaceable>TYPE</replaceable>
+                                               <replaceable>HOOK</replaceable>|<replaceable>TYPE</replaceable> list-hooks]</command>
                                </term>
 
                                <listitem>
                                                Calling <command>network help</command> without any
                                                arguments will show you this man page.
                                        </para>
+                                       <para>
+                                               <command>network help <replaceable>TYPE</replaceable> list-hooks</command>
+                                               will print a list of all hooks of <replaceable>TYPE</replaceable>.
+                                       </para>
                                        <para>
                                                You may optionally pass two arguments, to view the help
                                                of a certain hook.
index 719664e5293baa6f8660fa6e6c59e7e3beda429b..e65eb6bf92a9527f5d815afb2430f188cdfdac0b 100644 (file)
@@ -586,9 +586,6 @@ cli_zone() {
                        destroy)
                                cli_zone_destroy $@
                                ;;
-                       list-hooks)
-                               cli_list_hooks zone $@
-                               ;;
                        ""|*)
                                if [ -n "${action}" ]; then
                                        error "Unrecognized argument: '${action}'"
@@ -1192,26 +1189,36 @@ cli_reset() {
 # Optionally, there are two arguments taken, the type of hook
 # and which hook should be shown.
 cli_help() {
-       local type=${1}
-       local what=${2}
+       local cmd=${1}
+       shift
 
-       # Remove unknown types.
-       if ! listmatch ${type} zone port config; then
-               type=""
-       fi
+       case "${cmd}" in
+               zone|port|config)
+                       local type=${cmd}
+                       local hook=${1}
+
+                       # List all hooks if requested
+                       if [ "${hook}" = "list-hooks" ]; then
+                               cli_list_hooks ${type}
+                               return ${EXIT_OK}
+                       fi
 
-       # If no arguments were given, we will show the default page.
-       if [ -z "${type}" ]; then
-               cli_show_man network
-               return ${EXIT_OK}
-       fi
+                       if ! hook_exists ${type} ${hook}; then
+                               error "No hook with name '${hook}' could be found"
+                               exit "${EXIT_ERROR}"
+                       fi
 
-       if ! hook_exists ${type} ${what}; then
-               error "Hook of type '${type}' and name '${what}' could not be found."
-               exit "${EXIT_ERROR}"
-       fi
+                       hook_exec ${type} ${hook} help
+                       ;;
+
+               # In all other cases show the default man page
+               *)
+                       cli_show_man network
+                       return ${EXIT_OK}
+                       ;;
+       esac
 
-       hook_exec ${type} ${what} help
+       return ${EXIT_ERROR}
 }
 
 cli_dns_server() {