Closed
Description
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.