This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
howdy y'all,
i've been playing with a hobby script that shows a multi-level text menu and returns a valid-for-that-menu response. it works! [grin] that is nice.
[Power Shell] Get-MenuChoice - 2017.04.05.02.49 - Pastebin.com
- https://pastebin.com/5ghGb6Sj
however, i have a few requests ...
= a general critique will be appreciated.
= should i have the menu auto-append an exit selection or leave that to the menu that is fed to the function?
i'm doing it the 2nd way in the example at the bottom of that script.
= should i take the menu data structures and merge them into a single structure?
the current setup uses a string array for the menu list, a string for the optional prompt, and another optional string for the menu title. that makes for a very simple structure. lookee ...
$Choice = Get-MenuChoice -MenuItems ('1 - First item', '2 - Second item', 'x - Exit') -MenuTitle 'Menu Title' -MenuPrompt 'Pick one '
brain dead simple.
however, even when storing those items in variables to shorten the line, it can get l-o-n-g right quick. so i found myself using a splat ... that shows i could easily do it as a hashtable right from the get go.
but it would add a level of complexity that may not be worth it.
= plus, any other ideas y'all may want to pass on will be at least interesting. [grin]
take care,
lee
-ps
added that it is a text menu.
lee-
Subreddit
Post Details
- Posted
- 7 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PowerShell/...