PowerShell / PowerShell/PowerShell-RFC

Handling enums as cmdlet parameters.

Open
#396 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
467
Forks
140
Avg merge
9m
Merged PRs (30d)
1

Description

Summary of the new feature / enhancement

Changing the handling of enums as cmdlet parameters uses to display the possible values the values of the enum and the get the name for the value. Therefore xou get the same text if more than one name has the same value (see example below).

Proposed technical implementation details (optional)

<#
Display option when using an enum as a parameter of an CmdLet.
#>

Enum TestAction
{
Ignore = 0
Skip = 0
Replace = 1
New = 1
Remove = 2
Detete = 2

} # Enum TestAction

Function Test-Enum
{
param
(
[Parameter( Mandatory )]
[TestAction]
$Action
)
<#Do something#>

} # Function Test-Enum

<#
If you enter on a prompt
Test-Enum -Action
and try to select an action you get the following sequence:
Ignore
Ignore
Replace
Replace
Remove
Remove
Ignore
It would be nice to get the alias names as well.
Use [enum]::GetNames() instead [enum]::GetValues().
#>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with issue #396 and reproduce the enum cmdlet parameter completion example using duplicate enum values. Investigate the parameter-completion entry point that currently obtains enum values, then verify that completion exposes each name, including aliases such as Skip, New, and Detete, without duplicate value-based suggestions.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.