commandline
commandline copied to clipboard
AddEnumValuesToHelpText does not work for nullable enums
When outputting HelpText, the following code will correctly list valid values for enum type options. However, if the option is a nullable enum type, then it will not list the valid values.
parserResult.WithNotParsed(errors =>
{
// Use custom help text to ensure valid enum values are displayed
var helpText = HelpText.AutoBuild(parserResult);
helpText.AddEnumValuesToHelpText = true;
helpText.AddOptions(parserResult);
Console.Error.Write(helpText);
Environment.Exit(1);
});
Is this a bug, or is there another setting/workaround for nullable enums?