p-ranav / argparse

Argument Parser for Modern C++
MIT License
2.72k stars 250 forks source link

add_mutually_exclusive_group required in parent parser are not validated #316

Open CorrM opened 11 months ago

CorrM commented 11 months ago
argparse::ArgumentParser::MutuallyExclusiveGroup& syntaxGroup = genParser.add_mutually_exclusive_group(true);
    syntaxGroup.add_argument("--host")
            .help("Generate host syntax for target language.")
            .default_value(false)
            .implicit_value(true);
    syntaxGroup.add_argument("--guest")
            .help("Generate guest syntax for target language.")
            .default_value(false)
            .implicit_value(true);

    // Cpp
    argparse::ArgumentParser cppCommand("cpp");
    cppCommand.add_description("Generate C++ language SDK.");
    cppCommand.add_parents(genParser);

That will generate that output:

Positional arguments:
  CONFIG                 Configration file path. [required]

Optional arguments:
  -h, --help             shows help message and exits
  -v, --version          prints version information and exits
  -o, --output OUTPUT    Output directory path to store generated files. [required]
  --host                 Generate host syntax for target language.
  --guest                Generate guest syntax for target language.

If i don't pass --host or --guest will not throw any problem. (cpp C:\conf.yml -o C:\Generated)