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

Documentation for value_enum how to print possible values in help #3867

Closed
2 tasks done
stepancheg opened this issue Jun 25, 2022 · 1 comment
Closed
2 tasks done
Labels
C-enhancement Category: Raise on the bar on expectations

Comments

@stepancheg
Copy link
Contributor

Please complete the following tasks

Clap Version

3.2.5

Describe your use case

#[derive(ValueEnum, Clone)]
enum XxxMode {
}

    #[clap(
        long,
        value_enum,
    )]
    mode: XxxMode,

--help does not print possible values of enum.

Describe the solution you'd like

The solution I've found:

    #[clap(
        long,
        value_enum,
        possible_values = XxxMode::value_variants()
            .iter()
            .map(|v| v.to_possible_value().unwrap()),
    )]
    mode: XxxMode,

But it is not mentioned anywhere in documentation (e.g. in derive reference, or next to ValueEnum documentation).

(Also it should probably be default behavior to print possible values for value_enum).

Alternatives, if applicable

No response

Additional Context

No response

@stepancheg stepancheg added the C-enhancement Category: Raise on the bar on expectations label Jun 25, 2022
@stepancheg
Copy link
Contributor Author

Sorry, it works without this trick. Something didn't work before, but I don't know what I did when it didn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

1 participant