Skip to content
Discussion options

You must be logged in to vote

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 Count items.

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);
}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ajewellamz
Comment options

You must be logged in to vote
0 replies
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