summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2015-02-10 03:15:54 +0000
committerdteske <dteske@FreeBSD.org>2015-02-10 03:15:54 +0000
commit198d325e3bc2a79d3b1bacabdf214e8affbc5017 (patch)
treeb21385432d60fdffa7114d210928d71bfb91a135 /usr.sbin/bsdconfig
parent75d6eca5d3c8844a3e64aa001f9de9fe4fc04bea (diff)
downloadFreeBSD-src-198d325e3bc2a79d3b1bacabdf214e8affbc5017.zip
FreeBSD-src-198d325e3bc2a79d3b1bacabdf214e8affbc5017.tar.gz
Add bsdconfig api function f_dialog_menutag2help()
Diffstat (limited to 'usr.sbin/bsdconfig')
-rw-r--r--usr.sbin/bsdconfig/share/dialog.subr33
1 files changed, 33 insertions, 0 deletions
diff --git a/usr.sbin/bsdconfig/share/dialog.subr b/usr.sbin/bsdconfig/share/dialog.subr
index 13d209c..c83c0c6 100644
--- a/usr.sbin/bsdconfig/share/dialog.subr
+++ b/usr.sbin/bsdconfig/share/dialog.subr
@@ -2116,6 +2116,39 @@ f_dialog_menutag2index_with_help()
return $FAILURE
}
+# f_dialog_menutag2help $tag_chosen $tag1 $item1 $help1 $tag2 $item2 $help2 ...
+#
+# To use the `--menu' option of dialog(1) with the `--item-help' option, you
+# must pass an ordered list of tag/item/help triplets on the command-line. When
+# the user selects a menu option the tag for that item is printed to stderr.
+#
+# This function allows you to dereference the tag chosen by the user back into
+# the help associated with said tag (item is discarded/ignored).
+#
+# Pass the tag chosen by the user as the first argument, followed by the
+# ordered list of tag/item/help triplets (HINT: use the same tag/item/help list
+# as was passed to dialog(1) for consistency).
+#
+# If the tag cannot be found, NULL is returned.
+#
+f_dialog_menutag2help()
+{
+ local tag="$1" tagn help
+ shift 1 # tag
+
+ while [ $# -gt 0 ]; do
+ tagn="$1"
+ help="$3"
+ shift 3 # tagn/item/help
+
+ if [ "$tag" = "$tagn" ]; then
+ echo "$help"
+ return $SUCCESS
+ fi
+ done
+ return $FAILURE
+}
+
############################################################ INIT FUNCTIONS
# f_dialog_init
OpenPOWER on IntegriCloud