Skip to content

[BUG] Argparse does not handle argument de-duplication #405

@Jacobfaib

Description

@Jacobfaib

To reproduce:

int main(int argc, char *argv[])
{
  argparse::ArgumentParser program("program_name");

  program.add_argument("--foo")
         .default_value(1)  

  try {
    program.parse_args(argc, argv);
  } catch (const std::exception& err) {
    std::cerr << err.what() << std::endl;
    std::cerr << program;
    std::exit(1);
  }
}
$ ./example --foo 1 --foo 1
Duplicate argument --foo
...

The parser should simply accept the last value of the argument, to match the behavior of the majority of other argument parsers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions