Skip to content
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

Allow enum values to be given specific names and descriptions #9

Open
BradleyChatha opened this issue Nov 4, 2020 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@BradleyChatha
Copy link
Owner

Originally posted by @andrey-zherikov in #5 (comment):

Here you might want to allow @Description UDA that will be used in help text:

enum {
    @Description("Even returns 1. Odd returns 0.")
    normal,
    @Description("Even returns 0. Odd returns 1.")
    reversed
}

Thinking about this more, sometimes certain enum values should not be exposed to CLI caller and so shouldn't be printed on help screen. From the other side enum value might not be equal to CLI argument value, so here might be a better approach:

enum {
    @CommandArgValue("normal", "Even returns 1. Odd returns 0.")
    normal_mode,
    @CommandArgValue("reversed", "Even returns 0. Odd returns 1.")
    reverse_mode,

    some_reserved_mode,  // internal value that is not exposed to CLI
}

While I do like the idea, here's some points I need sorting out:

While a case like this will definitely happen, what should we do by default? If an enum has no @CommandArgValue members then do we provide the current behaviour, or do we force the user to provide @CommandArgValue every time for every enum for every enum value they want?

Any ideas or existing examples of how to format the help text to display this information?

@BradleyChatha BradleyChatha added the enhancement New feature or request label Nov 4, 2020
@BradleyChatha
Copy link
Owner Author

Just saw #5 (comment) which gives me a start on how the help text should look.

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

No branches or pull requests

1 participant