Skip to content

Is there a way to share common options from subcomands? #1766

Answered by pksunkara
Satoshi-Kusumoto asked this question in Q&A
Discussion options

You must be logged in to vote

I think you misunderstood what I meant.

let common_arg = Arg::with_name("option")
    .takes_value(true)
    .long("option");

let matches = App::new(name)
    .arg(common_arg.clone())
    .subcommand(
        SubCommand::with_name("subcommand")
            .arg(common_arg.clone())
    );

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

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