Any fool can write code that a computer can understand. Good programmers write code that humans can understand. -- Martin Fowler
Builds rich command line menu systems that are dynamic.
Create or recreate a menu and sets the 'working' menu.
> menu_create "key" "title"
# key: Key string used to reference the menu.
# title: Title string.
Sets the current working menu.
> menu_set "key"
Enables the 'All' option for the current working menu.
> menu_set_all_option_on
Disables the 'All' option for the current working menu.
> menu_set_all_option_off
Enables the 'All' option and sets it to default selection for the current working menu.
> menu_set_all_option_to_default
Enables auto-select for the current working menu. If the menu only contains one item it is automatically selected.
> menu_set_auto_select_on
Disables auto-select for the current working menu. If the menu only contains one item it is not automatically selected.
> menu_set_auto_select_off
Add a text item and value to the current working menu.
> menu_add_text [-default] ["itemText"] "itemValue"
# itemText:
# itemValue:
Add sub-menu and display text to current working menu.
> menu_add_menu "key" ["itemDisplay"]
# key:
# itemDisplay:
Add a command and display value as a menu item.
> menu_add_menu "command" ["itemDisplay"]
# command: Command string to run.
# itemDisplay: Display text.
Delete a specified menu or the current working menu.
> menu_delete ["key"]
# key:
>
Return true if the the last response was quit for the given menu.
> menu_was_quit "key"
Show the current menu.
> menu_show [-hide] [-select X] [-parent "X"] ["key"]
# -hide: Hide menu (for testing only).
# -select: Pre-selected item number (for testing only).
# -parent: Parent menu key.
# -quit: Quits menu after first item is selected.
Returns the number of items from the current working menu.
> menu_get_item_count
Delete all menus owned by the current Unix process ID.
> menu_delete_all_menus
# ```
# menu_delete_all_menus
# ```
Get the text value for the last selected item.
This assumes that the -all option was not available. If the -all option was used you should be using the menu_list_selected_items function.
> menu_get_selected_item "key"
#
# **Example**
# ```
# x=$(menu_get_selected_item "TestMenu")
# echo "You're response was ${x}."
# ```
Lists the text values of the selected items.
> menu_list_selected_items "key"
# **Example**
# ```
# menu_list_selected_items "TestMenu"
# ```
Return a list of menu items.
> menu_list_all_items "key"
Return the count of selected items for a menu.
> menu_get_selected_item_count "key"
Return true if menu exists.
> menu_does_menu_exist "key"