X Tutup
Skip to content

Feature Request: Variable Parameter with switch-like capability #12104

@chaydock

Description

@chaydock

What I'm looking for is the ability to use a parameter to pass a variable, yet be able to act similar to a switch. Essentially...

No parameter:
PS>FunctionName

Or, parameter used like a switch where it will utilize a default value
PS>FunctionName -Parameter

Or, parameter used with a specified override to the default value
PS>FunctionName -Parameter 123

The idea is that I have a need for a function to accept multiple switch style inputs to say enable/disable, use/don't-use a particular feature. To that end a switch parameter works fine. However, many of the parameters are not only a true/false but also a variable, and I want to be able to provide the user a way to override the default value. A second parameter could be specified and required with dynamic parameters, to which the the input might look as follows...

PS>FunctionName -Parameter -ParameterOverride 123

But, this is clunky at best and considering the function I'm presently trying to work with has need for 8 parameters of this style it's down right ugly to use from the users perspective.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup