Skip to content

How to use TrailingVarArg setting with clap_derive? #2217

Answered by olvyko
olvyko asked this question in Q&A
Discussion options

You must be logged in to vote

I managed to get this to work, needed to add the AllowLeadingHyphen setting

#[derive(Debug, Clap)]
#[clap(setting = AppSettings::TrailingVarArg, setting = AppSettings::AllowLeadingHyphen)]
pub struct Cmd {
    #[clap(multiple = true)]
    pub args: Vec<String>,
}
cmd --arg some -p text

# args: ["--arg", "some", "-p", "text"]

Replies: 1 comment

Comment options

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