-
Notifications
You must be signed in to change notification settings - Fork 481
Enum with Flags Attribute #247
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Hi @hallem can you give a few examples of the CLI UI you would expect to see for this feature? Something like this?
(the quotes are necessary because |
yeah that would work great. |
|
By the way, this is a workaround to get the behavior in the current system, but it does add an extra property to the options. I imagine it's similar to @hallem's original solution. void Main()
{
Parser.Default.ParseArguments<Options>("--color Blue Yellow".Split())
.WithParsed(o => o.BackgroundColor.Dump());
}
class Options
{
public Color BackgroundColor
{
get
{
return _BackgroundColors.Aggregate((Color)0, (o, c) => o | c);
}
}
[Option('c', "color")]
public IEnumerable<Color> _BackgroundColors { get; set; }
}
[Flags]
enum Color
{
Blue = 1,
Red = 2,
Yellow = 4
} |
@nemec That's basically what I'm doing now. Was just looking for a cleaner way to do it. |
@hallem Hi, you found solution? |
I was implementing this in a few of the console applications that I'm building and found that it would be really nice to have Flags support for an Enum. Right now the only solution is to use a collection of Enum values and then parse it out in code. Which is fine, but it would be a really nice to have if the library did that for you.
The text was updated successfully, but these errors were encountered: