Coming soon - Get a detailed view of why an account is flagged as spam!
view details

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.

6
seeking advice/critique on a hobby menu script
Post Body

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-

Author
Account Strength
100%
Account Age
11 years
Verified Email
Yes
Verified Flair
No
Total Karma
27,226
Link Karma
672
Comment Karma
25,727
Profile updated: 7 hours ago
Posts updated: 8 months ago
[grin]

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
7 years ago