Skip to content

FromAmong appends values rather than replaces them #1837

Closed

Description

@Keboo

Consider the following code:

using System.CommandLine;

Option<Pet> petOption = new("--pet");
petOption.FromAmong(Pet.Dog.ToString(), Pet.Cat.ToString());
RootCommand rootCommand = new()
{
    petOption
};

rootCommand.Invoke(args);


enum Pet
{
    Unknown,
    Dog, 
    Cat
}

This produces the following help output:

Description:

Usage:
  ConsoleApp2 [options]

Options:
  --pet <Cat|Dog|Unknown>
  --version                Show version information
  -?, -h, --help           Show help and usage information

FromAmong is documented as

Configures an option to accept only the specified values, and to suggest them as command line completions.

I expected it to override the default behavior of an enum option and use only the values that I specified.
This issue cam about because I was looking for a way to remove/overwrite the default completions that are generated for an Option's Argument.

Activity

  1. added
    bug
    Area-Completions
    on Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Completionsbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions