Skip to content
Snippets Groups Projects
Commit f63d7030 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

git subrepo pull packages/CLI11

subrepo:
  subdir:   "packages/CLI11"
  merged:   "b683f4ed9"
upstream:
  origin:   "git@github.com:CLIUtils/CLI11.git"
  branch:   "master"
  commit:   "b683f4ed9"
git-subrepo:
  version:  "0.4.0"
  origin:   "git@github.com:ingydotnet/git-subrepo.git"
  commit:   "5d6aba9"
parent b9ec061a
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
[subrepo]
remote = git@github.com:CLIUtils/CLI11.git
branch = master
commit = da901cca542612a133efcb04e8e78080186991e4
parent = 4348958e3bface85aedc9e8a5638f38790834cd5
cmdver = 0.3.1
commit = b683f4ed96b2da6c4992e63f49482b8c9cd00968
parent = b9ec061afdb0aefa3489d9beaecf99cd608f3d15
cmdver = 0.4.0
method = merge
......@@ -128,3 +128,7 @@ set_property(TEST subcom_in_files PROPERTY PASS_REGULAR_EXPRESSION
add_cli_exe(formatter formatter.cpp)
add_cli_exe(nested nested.cpp)
add_cli_exe(subcom_help subcom_help.cpp)
add_test(NAME subcom_help_normal COMMAND subcom_help sub --help)
add_test(NAME subcom_help_reversed COMMAND subcom_help --help sub)
#include <CLI/CLI.hpp>
#include <iostream>
int main(int argc, char *argv[]) {
CLI::App cli_global{"Demo app"};
auto &cli_sub = *cli_global.add_subcommand("sub", "Some subcommand");
std::string sub_arg;
cli_sub.add_option("sub_arg", sub_arg, "Argument for subcommand")->required();
CLI11_PARSE(cli_global, argc, argv);
if(cli_sub) {
std::cout << "Got: " << sub_arg << std::endl;
}
return 0;
}
json @ f1768a54
Subproject commit d2dd27dc3b8472dbaa7d66f83619b3ebcd9185fe
Subproject commit f1768a540a7b7c5cc30cdcd6be9e9ef91083719b
......@@ -1341,6 +1341,10 @@ class App {
// Verify required options
for(const Option_p &opt : options_) {
// Exit if a help flag was passed (requirements not required in that case)
if(_any_help_flag())
break;
// Required or partially filled
if(opt->get_required() || opt->count() != 0) {
// Make sure enough -N arguments parsed (+N is already handled in parsing function)
......@@ -1379,6 +1383,21 @@ class App {
}
}
/// Return True if a help flag detected (checks all parents)
bool _any_help_flag() const {
bool result = false;
const Option *help_ptr = get_help_ptr();
const Option *help_all_ptr = get_help_all_ptr();
if(help_ptr != nullptr && help_ptr->count() > 0)
result = true;
if(help_all_ptr != nullptr && help_all_ptr->count() > 0)
result = true;
if(parent_ != nullptr)
return result || parent_->_any_help_flag();
else
return result;
}
/// Parse one config param, return false if not found in any subcommand, remove if it is
///
/// If this has more than one dot.separated.name, go into the subcommand matching it
......@@ -1395,7 +1414,6 @@ class App {
if(level < item.parents.size()) {
App *subcom;
try {
std::cout << item.parents.at(level) << std::endl;
subcom = get_subcommand(item.parents.at(level));
} catch(const OptionNotFound &) {
return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment