Commit 3038540bd9968437a51b0617e6fba1d8f58f2b0d

Authored by Henry Schreiner
Committed by GitHub
1 parent 9cfa0f44

Help delete (#196)

* Getting a bit closer to Version 1.7

* Check and fix for deleting an option pointer directly that is also a help option. It is not common, but could be done
.ci/build_doxygen.sh
... ... @@ -3,7 +3,7 @@
3 3  
4 4 set -evx
5 5  
6   -DOXYGEN_URL="http://doxygen.nl/files/doxygen-1.8.14.src.tar.gz"
  6 +DOXYGEN_URL="http://doxygen.nl/files/doxygen-1.8.15.src.tar.gz"
7 7 cd "${DEPS_DIR}"
8 8  
9 9 if [[ ! -f "${DEPS_DIR}/doxygen/build/bin/doxygen" ]] ; then
... ...
CHANGELOG.md
1   -## Version 1.7.0: Parse breakup (in progress)
  1 +## Version 1.7.0: Parse breakup
2 2  
3 3 The parsing procedure now maps much more sensibly to complex, nested subcommand structures. Each phase of the parsing happens on all subcommands before moving on with the next phase of the parse. This allows several features, like required environment variables, to work properly even through subcommand boundaries.
4   -Passing the same subcommand multiple times is better supported. A few new features were added as well, including Windows style option support, parsing strings directly, and ignoring underscores in names.
  4 +Passing the same subcommand multiple times is better supported. Several new features were added as well, including Windows style option support, parsing strings directly, and ignoring underscores in names.
5 5  
6 6 * Support Windows style options with `->allow_windows_style_options`. [#187] On by default on Windows. [#190]
7 7 * Added `parse(string)` to split up and parse a command-line style string directly. [#186]
... ...
1   -CLI11 1.6 Copyright (c) 2017-2018 University of Cincinnati, developed by Henry
  1 +CLI11 1.7 Copyright (c) 2017-2018 University of Cincinnati, developed by Henry
2 2 Schreiner under NSF AWARD 1414736. All rights reserved.
3 3  
4 4 Redistribution and use in source and binary forms of CLI11, with or without
... ...
include/CLI/App.hpp
... ... @@ -1055,6 +1055,11 @@ class App {
1055 1055 op->remove_excludes(opt);
1056 1056 }
1057 1057  
  1058 + if(help_ptr_ == opt)
  1059 + help_ptr_ = nullptr;
  1060 + if(help_all_ptr_ == opt)
  1061 + help_all_ptr_ = nullptr;
  1062 +
1058 1063 auto iterator =
1059 1064 std::find_if(std::begin(options_), std::end(options_), [opt](const Option_p &v) { return v.get() == opt; });
1060 1065 if(iterator != std::end(options_)) {
... ...
include/CLI/Version.hpp
... ... @@ -6,8 +6,8 @@
6 6 // [CLI11:verbatim]
7 7  
8 8 #define CLI11_VERSION_MAJOR 1
9   -#define CLI11_VERSION_MINOR 6
10   -#define CLI11_VERSION_PATCH 2
11   -#define CLI11_VERSION "1.6.2"
  9 +#define CLI11_VERSION_MINOR 7
  10 +#define CLI11_VERSION_PATCH 0
  11 +#define CLI11_VERSION "1.7.0"
12 12  
13 13 // [CLI11:verbatim]
... ...
tests/HelpTest.cpp
... ... @@ -355,6 +355,49 @@ TEST(THelp, RemoveHelp) {
355 355 }
356 356 }
357 357  
  358 +TEST(THelp, RemoveOtherMethodHelp) {
  359 + CLI::App app{"My prog"};
  360 +
  361 + // Don't do this. Just in case, let's make sure it works.
  362 + app.remove_option(const_cast<CLI::Option *>(app.get_help_ptr()));
  363 +
  364 + std::string help = app.help();
  365 +
  366 + EXPECT_THAT(help, HasSubstr("My prog"));
  367 + EXPECT_THAT(help, Not(HasSubstr("-h,--help")));
  368 + EXPECT_THAT(help, Not(HasSubstr("Options:")));
  369 + EXPECT_THAT(help, HasSubstr("Usage:"));
  370 +
  371 + std::vector<std::string> input{"--help"};
  372 + try {
  373 + app.parse(input);
  374 + } catch(const CLI::ParseError &e) {
  375 + EXPECT_EQ(static_cast<int>(CLI::ExitCodes::ExtrasError), e.get_exit_code());
  376 + }
  377 +}
  378 +
  379 +TEST(THelp, RemoveOtherMethodHelpAll) {
  380 + CLI::App app{"My prog"};
  381 +
  382 + app.set_help_all_flag("--help-all");
  383 + // Don't do this. Just in case, let's make sure it works.
  384 + app.remove_option(const_cast<CLI::Option *>(app.get_help_all_ptr()));
  385 +
  386 + std::string help = app.help();
  387 +
  388 + EXPECT_THAT(help, HasSubstr("My prog"));
  389 + EXPECT_THAT(help, Not(HasSubstr("--help-all")));
  390 + EXPECT_THAT(help, HasSubstr("Options:"));
  391 + EXPECT_THAT(help, HasSubstr("Usage:"));
  392 +
  393 + std::vector<std::string> input{"--help-all"};
  394 + try {
  395 + app.parse(input);
  396 + } catch(const CLI::ParseError &e) {
  397 + EXPECT_EQ(static_cast<int>(CLI::ExitCodes::ExtrasError), e.get_exit_code());
  398 + }
  399 +}
  400 +
358 401 TEST(THelp, NoHelp) {
359 402 CLI::App app{"My prog"};
360 403 app.set_help_flag();
... ...