PowerShellOrg / Plaster

Plaster is a template-based file and project generator written in PowerShell.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multi Choice Allows for a Duplicate Shortcut Key

tommymaynard opened this issue · comments

The multi choice parameter allows you to use the same letter as a shortcut key for more than one choice.

<choice label="&amp;Private"
        help="Adds a Private folder to the module root."
        value="Private" />
<choice label="&amp;Public"
        help="Adds a Public folder to the module root."
        value="Public" />   

In the above example, if the letter "P" is used as a shortcut it will create both the Private and Public folder. My current work around is to use different letters.

<choice label="P&amp;rivate"
        help="Adds a Private folder to the module root."
        value="Private" />
<choice label="P&amp;ublic"
        help="Adds a Public folder to the module root."
        value="Public" />   

It seems buggy that Invoke-Plaster, and perhaps Test-PlasterManifest, would allow for this behavior. The expected behavior would be an indication to the user that there's a conflict, and that a different value should be used for one of the choice labels.

+1 I just ran into the same where I had to choices starting with the same letter

I tried looking at the code, and it doesn't seem that this is something that Plaster does automatically, it is a function of the [System.Management.Automation.Host.ChoiceDescription] Label property. It is based on where you place the &.

https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.host.choicedescription.label?view=powershellsdk-1.1.0#System_Management_Automation_Host_ChoiceDescription_Label

The workaround is the solution in this case I think.