Skip to content

Is it possible to have multiple references to the same argument? #5608

Answered by epage
guzzit asked this question in Q&A
Discussion options

You must be logged in to vote

Oh, right, the Arg::id

#[derive(Debug, Default, clap::Args, Clone, PartialEq, Eq)]
pub struct PlantArgs {
    #[clap(long, env = "TYPE")]
    pub plant_type: String,
}

#[derive(Debug, Default, clap::Args, Clone, PartialEq, Eq)]
pub struct WoodArgs {
    #[clap(long, env = "TYPE")]
    pub wood_type: String,
}

or

#[derive(Debug, Default, clap::Args, Clone, PartialEq, Eq)]
pub struct PlantArgs {
    #[clap(long = "plant-type", id = "plant-type", env)]
    pub type: String,
}

#[derive(Debug, Default, clap::Args, Clone, PartialEq, Eq)]
pub struct WoodArgs {
    #[clap(long = "wood-type", id = "wood-type", env)]
    pub type: String,
}

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@guzzit
Comment options

@epage
Comment options

@guzzit
Comment options

@epage
Comment options

Answer selected by guzzit
@guzzit
Comment options

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