Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/CLI/App.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,9 @@ class App {
auto *ptr = option_group.get();
// move to App_p for overload resolution on older gcc versions
App_p app_ptr = std::dynamic_pointer_cast<App>(option_group);
// don't inherit the footer in option groups and clear the help flag by default
app_ptr->footer_ = "";
app_ptr->set_help_flag();
add_subcommand(std::move(app_ptr));
return ptr;
}
Expand Down
19 changes: 19 additions & 0 deletions tests/HelpTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ TEST_CASE("THelp: FooterCallbackBoth", "[help]") {
CHECK_THAT(help, Contains("foot!!!!"));
}

/// @brief from github issue #1156
TEST_CASE("THelp: FooterOptionGroup", "[help]") {
CLI::App app{"My prog"};

app.footer("Report bugs to bugs@example.com");

app.add_option_group("group-a", "");

app.add_option_group("group-b", "");

std::string help = app.help();

auto footer_loc = help.find("bugs@example.com");
auto footer_loc2 = help.find("bugs@example.com", footer_loc + 10);
CHECK(footer_loc != std::string::npos);
// should only see the footer once
CHECK(footer_loc2 == std::string::npos);
}

TEST_CASE("THelp: OptionalPositional", "[help]") {
CLI::App app{"My prog", "program"};

Expand Down
Loading