<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>
<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.
destroy)
cli_zone_destroy $@
;;
- list-hooks)
- cli_list_hooks zone $@
- ;;
""|*)
if [ -n "${action}" ]; then
error "Unrecognized argument: '${action}'"
# 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() {