-
Notifications
You must be signed in to change notification settings - Fork 38
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
Allow for Parameter values to be translated via key/value pair #139
Comments
I second this enhancement request. In my case, I would like to combine multiple options that are mutually-exclusive on msiexec into a single PowerShell parameter. I can achieve this today with the following: {
"OriginalName": "/q",
"Name": "UserInterfaceMode",
"ParameterType": "string",
"AdditionalParameterAttributes": [
"[ValidateSet('n','n+','b','b+','r','f')]"
],
"Mandatory": false,
"Description": "Specifies the UI during the installation process.",
"NoGap": true
}, But I would like the PowerShell command to have more descriptive values: {
"OriginalName": "/q",
"Name": "UserInterfaceMode",
"ParameterType": "string",
"ParameterValues": [
{
"None": "n",
"Basic": "b",
"Reduced": "r",
"Full": "f"
}
],
"AdditionalParameterAttributes": [
"[ValidateSet('None','Basic','Reduced','Full')]"
],
"Mandatory": false,
"Description": "Specifies the UI during the installation process.",
"NoGap": true
}, Another example is the mutually exclusive restart options on msiexec. |
I've been messing about with various bits and have this functionality in an experimental branch at This sample https://github.com/jhoneill/Crescendo/blob/James/Microsoft.PowerShell.Crescendo/Samples/Install-Program.crescendo.json does what @jasoth is suggesting . The JSON has this
The resulting parameter looks like this [ValidateSet('None', 'Full', 'Basic', 'Reduced')]
[PSDefaultValue(Value='Basic')]
[string]$UIMode="Basic" The parameter map has this $parameterMap = @{
UIMode = @{
OriginalName = '/q'
OriginalPosition = '0'
ParameterType = 'string'
ApplyToExecutable = $False
NoGap = $True
DefaultValue = 'Basic'
ValueMap = @{ 'Reduced' = 'r'; 'None' = 'n'; 'Basic' = 'b'; 'Full' = 'f' }
}
} and the body of the code has this $parameterMap.Keys | Where-Object {$parameterMap[$_].containskey('ValueMap') -and $boundParameters.ContainsKey($_)} |
ForEach-Object { $boundParameters[$_] = $parameterMap[$_].ValueMap[$boundParameters[$_]]} So for any passed parameter whose entry in the |
@EmeraldFlame - This is interesting and has merit. I also think @jhoneill example is a good start - but we have some open questions to think through. I'll come back with questions ;) |
related to #31 |
I'd like to recommend adding the ability to translate the input given in the PowerShell command to a different value that actually gets used on the cmd side. This would allow crescendo modules to offer cleaner and clearer options to end users when the naming, notation, or syntax of the cmd tool isn't necessarily intuitive.
One such example I can think of where this would be helpful would be with 7-Zip's recursion switch.
In condensed form
The syntax for this really isn't clear on what it does, you have to go out to the documentation site to understand it. For a crescendo command, I think it'd be preferable to do something like:
But in this instance, instead of passing the actual value given, it'd be preferable to pass the accompanying value it translates to (ie, '-', $null, or '0').
As a very quick mock-up, I could see this being implemented in roughly the following manner
The text was updated successfully, but these errors were encountered: