Skip to content

Pipe character for listing options e.g. --option [RED|GREEN|BLUE] #1434

@peteristhegreat

Description

@peteristhegreat

Is your feature request related to a problem? Please describe.
Right now, if I describe a CommandSetting with [CommandOption("--option [RED|GREEN|BLUE]")], it fails with

Error: An error occured when parsing template.
       Encountered invalid character '|' in value name.

       --option [RED|GREEN|BLUE]
                    ^ Invalid character

Likely caused by this line:
https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console.Cli/Internal/Configuration/TemplateParser.cs#L91

Describe the solution you'd like
I don't really expect the validation to use the list I put in the help text, but I would like it to allow the concise help to be able to show a list of acceptable answers instead of having to put it in the description.

Describe alternatives you've considered
I tried commas, and with angle brackets.

I think my next best workaround is something like:

[CommandOption("--option <RED_or_GREEN_or_BLUE>")]

or

[CommandOption("--option <COLOR>")]
[Description("Options for COLOR are RED, GREEN, or BLUE.")]

But both of the above doesn't seem quite as concise as my proposed solution of supporting the pipe character.

Additional context
If there is a better way to do this for this library, maybe seeing an example in the docs would be nice.

Also, thanks for the awesome library. The docs are awesome, and I am loving the experience using it so far.


Please upvote 👍 this issue if you are interested in it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions