* [PATCH] zone: add new command config list
@ 2017-07-10 13:33 Jonatan Schlag
0 siblings, 0 replies; only message in thread
From: Jonatan Schlag @ 2017-07-10 13:33 UTC (permalink / raw)
To: network
[-- Attachment #1: Type: text/plain, Size: 1331 bytes --]
With the new command
network <zone> config list
a user can get all configured configs with id and hook.
Fixes: #11407
Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
src/functions/functions.zone | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/functions/functions.zone b/src/functions/functions.zone
index d121225..ff6d945 100644
--- a/src/functions/functions.zone
+++ b/src/functions/functions.zone
@@ -560,6 +560,9 @@ zone_config() {
edit)
zone_config_edit "${zone}" "$@"
;;
+ list)
+ zone_config_list "${zone}" "$@"
+ ;;
*)
# Check is we get a valid id
# TODO This could be also a valid hid
@@ -613,6 +616,30 @@ zone_config_edit() {
zone_config_cmd "edit" "$@"
}
+zone_config_list() {
+ # This function list in an nice way all configs of a zone
+ local zone=${1}
+ assert isset zone
+
+ # Print a nice header
+ local format="%-3s %-20s"
+ print "${format}" "ID" "HOOK"
+
+ local config
+ local hook
+ local id
+
+ # Print for all config:
+ # id and hook
+ # TODO: Add hids here
+ for config in $(zone_configs_list "${zone}"); do
+ id=${config##*.}
+ hook=$(zone_config_get_hook "${zone}" "${config}")
+ assert isset hook
+ print "${format}" "${id}" "${hook}"
+ done
+}
+
zone_config_show() {
zone_config_cmd "show" "$@"
}
--
2.6.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-07-10 13:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-10 13:33 [PATCH] zone: add new command config list Jonatan Schlag
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox