Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show-Menu do not accept arrays as items #12

Closed
krypt-lynx opened this issue Jun 7, 2022 · 1 comment
Closed

Show-Menu do not accept arrays as items #12

krypt-lynx opened this issue Jun 7, 2022 · 1 comment

Comments

@krypt-lynx
Copy link

krypt-lynx commented Jun 7, 2022

I'm tried to cut a corner by not describing a custom class:

Show-Menu -MenuItems @(("test1", 1), @("test2", 2)) -MenuItemFormatter { $Args[0] }

But got an exception instead

Actual Result:
Exception thrown

The -MenuItems option only contains non-selectable menu-items (like separators)
At C:\Program Files\WindowsPowerShell\Modules\PSMenu\0.1.8\Private\Test-MenuItemArray.ps1:9 char:5
+     Throw 'The -MenuItems option only contains non-selectable menu-it ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (The -MenuItems ...ike separators):String) [], RuntimeException
    + FullyQualifiedErrorId : The -MenuItems option only contains non-selectable menu-items (like separators)

Expected Result
Menu containing items "test1" and "test2" shown

@Sebazzz
Copy link
Owner

Sebazzz commented Jun 20, 2022

Thank you for your report. Fixed in v0.1.9.

Note that in your case you need to use:

Show-Menu -MenuItems @(@("test1", 1), @("test2", 2)) -MenuItemFormatter { param($X) $X[0] }

Or $Args[0][0] because $Args itself is an array of arguments which contains one item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants