Need indices_of for flags #6246
-
|
I need a command line like this
Is this impossible, or am I missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Something we fixes in clap v4 is to make it so there is a direct mapping between values and indices. This had the side effect of making it so we only have 1 index for See also #6042 A potential way to workaround this is to make a custom flag and manually count the results: #!/usr/bin/env nargo
---
[dependencies]
clap = "4"
---
fn main() {
let cmd = clap::Command::new("foo").arg(
clap::Arg::new("count")
.long("count")
.action(clap::builder::ArgAction::Append)
.num_args(0)
.default_missing_value("present"),
);
let m = cmd.get_matches();
dbg!(&m);
} |
Beta Was this translation helpful? Give feedback.
-
|
Many thanks, that's what I needed. |
Beta Was this translation helpful? Give feedback.
Something we fixes in clap v4 is to make it so there is a direct mapping between values and indices. This had the side effect of making it so we only have 1 index for
Countitems.See also #6042
A potential way to workaround this is to make a custom flag and manually count the results: