Support flags with Enum type.
alexpantyukhin opened this issue · 0 comments
alexpantyukhin commented
For now the lib supports string
and bool
properties for commands flag. What if to support enum
properties? The lib could validate the passed value and show the list of valid values in the help
.
Any thoughts?
enum Color
{
Red,
Green,
Blue
}
[Command("colorer", "Prints a color opinion.")]
class SayHelloCommand : ICommand
{
[CommandArgument("c", "color", Description = "The color", DefaultValue = Color.Green)]
public Color Color { get; set; }
[CommandOutput]
public IOutput Output { get; set; }
public int Execute()
{
if (Color == Color.Red)
{
Output.WriteInfo("Oh, no! Red color!");
return ReturnCode.Failure;
}
if (Color == Color.Yellow)
{
Output.WriteInfo("Yellow color is better, but not enough!");
return ReturnCode.Failure;
}
Output.WriteInfo("Green color is awesome!!");
return ReturnCode.Success;
}
}