You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include"CLI11.hpp"intmain(int argc, char* argv[])
{
bool printConfig = false;
std::string sub_arg;
CLI::App cli_global {"Demo app"};
cli_global.set_config("--config", "config.cfg", "Load configuration from a file", true);
cli_global.set_help_flag("--help-group", "Print help of single group");
cli_global.add_flag("--print-config", printConfig, "Print current config to stdout and exit\n")->configurable(false);
cli_global.add_option("base_arg", sub_arg, "Argument for root");
auto& cli_sub = *cli_global.add_subcommand("sub", "Some subcommand");
cli_sub.add_option("sub_arg", sub_arg, "Argument for subcommand");
cli_sub.add_option("sub_arg2", sub_arg, "Argument for subcommand2");
cli_sub.configurable();
auto& cli_sub2 = *cli_global.add_subcommand("sub2", "Some subcommand");
cli_sub2.add_option("sub_arg", sub_arg, "Argument for subcommand");
cli_sub2.add_option("sub_arg2", sub_arg, "Argument for subcommand2");
cli_sub2.configurable();
CLI11_PARSE(cli_global, argc, argv);
if(printConfig)
{
std::cout << cli_global.config_to_str(true, true) << '\n';
}
return0;
}
Output for main.exe --print-config
# Demo app# Argument for rootbase_arg=""# Some subcommand# Argument for subcommandsub.sub_arg=""# Argument for subcommand2sub.sub_arg2=""# Some subcommand# Argument for subcommandsub2.sub_arg=""# Argument for subcommand2sub2.sub_arg2=""
Expected, can be achieved by listing all sections in command line: main.exe sub sub2 --print-config
# Demo app# Argument for rootbase_arg=""
[sub]
# Some subcommand# Argument for subcommandsub_arg=""# Argument for subcommand2sub_arg2=""
[sub2]
# Some subcommand# Argument for subcommandsub_arg=""# Argument for subcommand2sub_arg2=""
Fix docstring related to #1052
Fix config_to_string with defaults #1007
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Given the code:
Output for
main.exe --print-config
Expected, can be achieved by listing all sections in command line:
main.exe sub sub2 --print-config
Simple fix, I am not sure if it covers all cases:
The text was updated successfully, but these errors were encountered: