Skip to content
Discussion options

You must be logged in to vote

Is there an idiomatic way to simplify this code?

Not really and yes at the same time.

Is there a way to autogenerate the .long argument given the argument name?

Yes, but you may not like it.

Can I, for example, set all arguments as required and takes_value by default?

No. Just no. I really don't like global switches that drastically change behavior of the library.


There is alternative way to make an Arg - Arg::from_usage (Arg::from in upcoming 3.0).
Playground

App::new("MyApp")
    .arg(Arg::from_usage("--our-test-results <path>")
        // separate call since the help string is quite lengthy 
        .help("path to output of running our tests on their solution")
    )
    // the …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by pksunkara
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants