Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

m_is_used not updated in parent of subcommand #314

Open
CorrM opened this issue Dec 10, 2023 · 0 comments
Open

m_is_used not updated in parent of subcommand #314

CorrM opened this issue Dec 10, 2023 · 0 comments

Comments

@CorrM
Copy link

CorrM commented Dec 10, 2023

argparse::ArgumentParser program("test", "0.0.1");
    argparse::ArgumentParser genParser("gen", "0.0.1", argparse::default_arguments::none);
    genParser.add_argument("-c", "--config")
            .help("Configration file path.")
            .metavar("CONFIG")
            .required();

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

    cppCommand.add_argument("--namespace")
            .help("Set the C++ namespace for the generated SDK.")
            .metavar("NAMESPACE")
            .action([&properties](const std::string& value){ properties.emplace_back("namespace", value); });

    program.add_subparser(cppCommand);

    // CSharp
    argparse::ArgumentParser csharpCommand("csharp");
    csharpCommand.add_description("Generate C# language SDK.");
    csharpCommand.add_parents(genParser);

    program.add_subparser(csharpCommand);

    // Python
    argparse::ArgumentParser pythonCommand("python");
    pythonCommand.add_description("Generate Python language SDK.");
    pythonCommand.add_parents(genParser);

    program.add_subparser(pythonCommand);
std::string configPath = program.get("-c"); // No such argument: -c
std::string configPath = genParser.get("-c"); // Nothing parsed, no arguments are available.
std::string configPath = cppCommand.get("-c"); // Work

when i debug, genParser have the the argument but argument field are not updated.
as workaround i could do some condition around is_subcommand_used but i think its not the correct way to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant