Skip to content

Enum with flags that can be combined #582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dfhwze opened this issue Feb 9, 2020 · 2 comments
Closed

Enum with flags that can be combined #582

dfhwze opened this issue Feb 9, 2020 · 2 comments
Labels

Comments

@dfhwze
Copy link

dfhwze commented Feb 9, 2020

Is it possible to have flagged enum options?

For instance, I would like to be able to combine which categories I would like to log in my tool.

command-line:

mytool -l Admin -l Status

enum used in options:

[Flags]
public enum Logging: uint
{
None = 0,
Admin = 1 << 0,
Status = 1 << 1,
Progress = 1 << 2,
All = 0xFFFFFFFF,
}

@moh-hassan
Copy link
Collaborator

You can use IEnumerable<Logging> for multiple options and use separator '|' like c#:

 public class Options
    {
       [Option('l',  Separator='|')]  
       public IEnumerable<Logging> Log { get; set; }
    }

commandline can be:

mytool -l Admin|Status|Progress 

Then Evaluate the multi log values.

@moh-hassan
Copy link
Collaborator

@dfhwze
Can you feedback if you resolved your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants