argparse icon indicating copy to clipboard operation
argparse copied to clipboard

[BUG] Argparse does not handle argument de-duplication

Open Jacobfaib opened this issue 6 months ago • 2 comments

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

Jacobfaib avatar Jun 12 '25 23:06 Jacobfaib

亲,来信已经收到!祝你快乐!

wanjiadenghuo111 avatar Jun 12 '25 23:06 wanjiadenghuo111

related to #397

Jacobfaib avatar Jun 12 '25 23:06 Jacobfaib