-
I'm trying to make an argument that can have multiple occurrences with possible multiple values. Something like this, command --copy /from --copy /from /to Here's my try at a derived parser, #[derive(Parser, Debug)]
struct Args {
#[arg(short, long, value_delimiter = ' ', num_args = 1..=2)]
pub copy: Vec<Vec<PathBuf>>,
} At the moment however the compiler complains about this,
Is it possible to have such an argument? Using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
tl;dr run Whats happening is the derive sees Multiple values per occurrence is generally handled as a flat structure ( |
Beta Was this translation helpful? Give feedback.
tl;dr run
cargo add clap -F unstable-v5
but keep in mind the other breaking changes with that feature and that we may introduce more until we release clap v5.0.0.Whats happening is the derive sees
Vec<T>
and treats that as multiple occurrences ofT
but clap doesn't know (and an attribute wasn't specified) to say how to parseVec<PathBuf>
out of a single value.Multiple values per occurrence is generally handled as a flat structure (
Vec<T>
). We've slowly been adding support for grouping values per occurrence. Supporting this in the derive would technically be a breaking change (#4626) which won't be available until clap v5. We have implemented support for this behind theunstable-v5
featu…