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

Explicitly doc the usage of ArgEnum #3638

Closed
2 tasks done
Banyc opened this issue Apr 18, 2022 · 5 comments
Closed
2 tasks done

Explicitly doc the usage of ArgEnum #3638

Banyc opened this issue Apr 18, 2022 · 5 comments
Labels
C-enhancement Category: Raise on the bar on expectations

Comments

@Banyc
Copy link

Banyc commented Apr 18, 2022

Please complete the following tasks

Clap Version

3.1.9

Describe your use case

Searching google for "rust clap enum example" yields no results or outdated macro arg_enum.

The expected answer should be:

#[derive(clap::Parser)]
struct Args {
    #[clap(arg_enum)]
    level: Level,
}

#[derive(clap::ArgEnum, Clone)]
enum Level {
    Debug,
    Info,
    Warning,
    Error,
}

Describe the solution you'd like

Explicitly show the example and usage in README.md.

Alternatives, if applicable

No response

Additional Context

No response

@Banyc Banyc added the C-enhancement Category: Raise on the bar on expectations label Apr 18, 2022
@epage
Copy link
Member

epage commented Apr 18, 2022

You have several routes to the documentation

  • On the arg_enum page, click "Go to latest release" and show a search result for the ArgEnum trait which gives a derive example
  • On the docs click on "Tutorial: .... Derive API" and scroll down to the validation section for enumerated values
  • On the docs click on "Derive Reference" and you will see how to use it and what attributes are supported.

@Banyc
Copy link
Author

Banyc commented Apr 19, 2022

@epage I totally ok with the suggestions as a user who have just found the correct usage. But as for new learners stumbling across this, they might still find it a hard time looking for answers. In their (including mine) points of views, the doc is not clear and easy enough, especially comparing to that of C#. I am really impressed by Rust language and its safety features. That's why I want the ecosystem around the language could be more friendly to new learners. I hope the usage is only one search away, not nested in links within links imho.

@epage
Copy link
Member

epage commented Apr 19, 2022

Isn't that similar to our tutorial, with the main difference being that our code isn't inline?

The lack of inline code is not great but its a side effect of making our code samples testable. If we switched to a mdbook, we could have them inline. #3189 is exploring the needs for our derive documentation.

What I'm trying to understand is a concrete user need that we can explore improving or a concrete solution we can evaluate applying.

@Banyc
Copy link
Author

Banyc commented Apr 19, 2022

@epage

a concrete solution

I fully agree with this!

@epage
Copy link
Member

epage commented Apr 20, 2022

Without anything actionable and the fact that the reported problem (documenting ArgEnum) is done, I'm going to go ahead and close this. If you have specific concerns or specific solutions, feel free to open new issues.

@epage epage closed this as completed Apr 20, 2022
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

2 participants