System.CommandLine version: 2.0.0-beta6.25320.118
Defining an CliOption<T> with an enum type and its arity being set to ArgumentArity.Zero, the help output nevertheless suggests the option accepts values despite its arity being set to ArgumentArity.Zero and it not really accepting any values.
Looking at the code that generates the help output, the suggested values seem to come from a completion source. While i haven't tested completions myself, this suggests that not only help output but also completions for such options is broken.
Code to reproduce
Note that all options have an arity of Zero and a custom parser that produces the set/combination of animals the respective option represents.
var optionCarnivores = new Option<Animals>("-c")
{
Description = "Select carnivores",
Arity = ArgumentArity.Zero,
CustomParser = _ => Animals.Cat | Animals.Dog | Animals.Gecko
};
var optionInsectivores = new Option<Animals>("-i")
{
Description = "Select insectivores",
Arity = ArgumentArity.Zero,
CustomParser = _ => Animals.Gecko
};
var optionHerbivores = new Option<Animals>("-h")
{
Description = "Select herbivores",
Arity = ArgumentArity.Zero,
CustomParser = _ => Animals.Giraffe | Animals.Gnu
};
var rootCmd = new RootCommand
{
optionCarnivores,
optionInsectivores,
optionHerbivores
};
rootCmd.Parse("--help").Invoke();
[Flags]
public enum Animals
{
Cat = 1,
Dog = 2,
Gecko = 4,
Giraffe = 8,
Gnu = 16
}
Expected help output for the -c, -i, -h option
-c Select carnivores
-i Select insectivores
-h Select herbivores
Actual help output
-c <Cat|Dog|Gecko|Giraffe|Gnu> Select carnivores
-i <Cat|Dog|Gecko|Giraffe|Gnu> Select insectivores
-h <Cat|Dog|Gecko|Giraffe|Gnu> Select herbivores
This help output is incorrect, as the options -c, -i and -h do not accept any values.
System.CommandLine version: 2.0.0-beta6.25320.118
Defining an
CliOption<T>with an enum type and its arity being set toArgumentArity.Zero, the help output nevertheless suggests the option accepts values despite its arity being set toArgumentArity.Zeroand it not really accepting any values.Looking at the code that generates the help output, the suggested values seem to come from a completion source. While i haven't tested completions myself, this suggests that not only help output but also completions for such options is broken.
Code to reproduce
Note that all options have an arity of Zero and a custom parser that produces the set/combination of animals the respective option represents.
Expected help output for the -c, -i, -h option
Actual help output
This help output is incorrect, as the options
-c,-iand-hdo not accept any values.