Skip to content

Commit e2270dd

Browse files
authored
fix: fixed footer newline behavior (#796)
* fix: show newline before footer only if footer is set and not empty * chore: tests corrected for new help message formatting.
1 parent 25274e2 commit e2270dd

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

include/CLI/impl/Formatter_inl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ CLI11_INLINE std::string Formatter::make_footer(const App *app) const {
137137
if(footer.empty()) {
138138
return std::string{};
139139
}
140-
return footer + "\n";
140+
return "\n" + footer + "\n";
141141
}
142142

143143
CLI11_INLINE std::string Formatter::make_help(const App *app, std::string name, AppFormatMode mode) const {
@@ -159,7 +159,7 @@ CLI11_INLINE std::string Formatter::make_help(const App *app, std::string name,
159159
out << make_positionals(app);
160160
out << make_groups(app, mode);
161161
out << make_subcommands(app, mode);
162-
out << '\n' << make_footer(app);
162+
out << make_footer(app);
163163

164164
return out.str();
165165
}

tests/FormatterTest.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ TEST_CASE("Formatter: OptCustomize", "[formatter]") {
6363
"Usage: [OPTIONS]\n\n"
6464
"Options:\n"
6565
" -h,--help Print this help message and exit\n"
66-
" --opt INT (MUST HAVE) Something\n\n");
66+
" --opt INT (MUST HAVE) Something\n");
6767
}
6868

6969
TEST_CASE("Formatter: OptCustomizeSimple", "[formatter]") {
@@ -82,7 +82,7 @@ TEST_CASE("Formatter: OptCustomizeSimple", "[formatter]") {
8282
"Usage: [OPTIONS]\n\n"
8383
"Options:\n"
8484
" -h,--help Print this help message and exit\n"
85-
" --opt INT (MUST HAVE) Something\n\n");
85+
" --opt INT (MUST HAVE) Something\n");
8686
}
8787

8888
TEST_CASE("Formatter: OptCustomizeOptionText", "[formatter]") {
@@ -100,7 +100,7 @@ TEST_CASE("Formatter: OptCustomizeOptionText", "[formatter]") {
100100
"Usage: [OPTIONS]\n\n"
101101
"Options:\n"
102102
" -h,--help Print this help message and exit\n"
103-
" --opt (ARG) Something\n\n");
103+
" --opt (ARG) Something\n");
104104
}
105105

106106
TEST_CASE("Formatter: FalseFlagExample", "[formatter]") {
@@ -140,7 +140,7 @@ TEST_CASE("Formatter: AppCustomize", "[formatter]") {
140140
" -h,--help Print this help message and exit\n\n"
141141
"Subcommands:\n"
142142
" subcom1 This\n"
143-
" subcom2 This\n\n");
143+
" subcom2 This\n");
144144
}
145145

146146
TEST_CASE("Formatter: AppCustomizeSimple", "[formatter]") {
@@ -159,7 +159,7 @@ TEST_CASE("Formatter: AppCustomizeSimple", "[formatter]") {
159159
" -h,--help Print this help message and exit\n\n"
160160
"Subcommands:\n"
161161
" subcom1 This\n"
162-
" subcom2 This\n\n");
162+
" subcom2 This\n");
163163
}
164164

165165
TEST_CASE("Formatter: AllSub", "[formatter]") {

tests/HelpTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ TEST_CASE_METHOD(CapturedHelp, "CallForAllHelpOutput", "[help]") {
813813
" One description\n\n"
814814
"two\n"
815815
" Options:\n"
816-
" --three \n\n\n");
816+
" --three \n\n");
817817
}
818818
TEST_CASE_METHOD(CapturedHelp, "NewFormattedHelp", "[help]") {
819819
app.formatter_fn([](const CLI::App *, std::string, CLI::AppFormatMode) { return "New Help"; });

0 commit comments

Comments
 (0)