Position rest arguments before required arguments #5473
Answered
by
epage
KAAtheWiseGit
asked this question in
Q&A
-
Good day!
struct Cp {
src: Vec<PathBuf>,
dst: PathBuf,
}
// Found non-required positional argument with a lower index than a required positional argument: "paths" index Some(1) Is there a way to bypass this behavior? And if not, is it possible to overwrite the usage text, so that it shows struct Cp {
#[arg(id = "[PATHS]... <DST>")]
paths: Vec<PathBuf>,
}
// Usage: cp [OPTIONS] [[PATHS]... <DST>]... |
Beta Was this translation helpful? Give feedback.
Answered by
epage
Apr 23, 2024
Replies: 1 comment 1 reply
-
Clap does not support that. We have very limited support for optional non-last argument. To override the usage, |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
KAAtheWiseGit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Clap does not support that. We have very limited support for optional non-last argument.
To override the usage,
Command::override_usage
can be used as an attribute#[command(override_usage = "")]