mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-08 15:53:51 +00:00
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.
This commit is contained in:
parent
25274e2c7b
commit
e2270dd6f8
@ -137,7 +137,7 @@ CLI11_INLINE std::string Formatter::make_footer(const App *app) const {
|
|||||||
if(footer.empty()) {
|
if(footer.empty()) {
|
||||||
return std::string{};
|
return std::string{};
|
||||||
}
|
}
|
||||||
return footer + "\n";
|
return "\n" + footer + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
CLI11_INLINE std::string Formatter::make_help(const App *app, std::string name, AppFormatMode mode) const {
|
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,
|
|||||||
out << make_positionals(app);
|
out << make_positionals(app);
|
||||||
out << make_groups(app, mode);
|
out << make_groups(app, mode);
|
||||||
out << make_subcommands(app, mode);
|
out << make_subcommands(app, mode);
|
||||||
out << '\n' << make_footer(app);
|
out << make_footer(app);
|
||||||
|
|
||||||
return out.str();
|
return out.str();
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ TEST_CASE("Formatter: OptCustomize", "[formatter]") {
|
|||||||
"Usage: [OPTIONS]\n\n"
|
"Usage: [OPTIONS]\n\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -h,--help Print this help message and exit\n"
|
" -h,--help Print this help message and exit\n"
|
||||||
" --opt INT (MUST HAVE) Something\n\n");
|
" --opt INT (MUST HAVE) Something\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Formatter: OptCustomizeSimple", "[formatter]") {
|
TEST_CASE("Formatter: OptCustomizeSimple", "[formatter]") {
|
||||||
@ -82,7 +82,7 @@ TEST_CASE("Formatter: OptCustomizeSimple", "[formatter]") {
|
|||||||
"Usage: [OPTIONS]\n\n"
|
"Usage: [OPTIONS]\n\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -h,--help Print this help message and exit\n"
|
" -h,--help Print this help message and exit\n"
|
||||||
" --opt INT (MUST HAVE) Something\n\n");
|
" --opt INT (MUST HAVE) Something\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Formatter: OptCustomizeOptionText", "[formatter]") {
|
TEST_CASE("Formatter: OptCustomizeOptionText", "[formatter]") {
|
||||||
@ -100,7 +100,7 @@ TEST_CASE("Formatter: OptCustomizeOptionText", "[formatter]") {
|
|||||||
"Usage: [OPTIONS]\n\n"
|
"Usage: [OPTIONS]\n\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -h,--help Print this help message and exit\n"
|
" -h,--help Print this help message and exit\n"
|
||||||
" --opt (ARG) Something\n\n");
|
" --opt (ARG) Something\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Formatter: FalseFlagExample", "[formatter]") {
|
TEST_CASE("Formatter: FalseFlagExample", "[formatter]") {
|
||||||
@ -140,7 +140,7 @@ TEST_CASE("Formatter: AppCustomize", "[formatter]") {
|
|||||||
" -h,--help Print this help message and exit\n\n"
|
" -h,--help Print this help message and exit\n\n"
|
||||||
"Subcommands:\n"
|
"Subcommands:\n"
|
||||||
" subcom1 This\n"
|
" subcom1 This\n"
|
||||||
" subcom2 This\n\n");
|
" subcom2 This\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Formatter: AppCustomizeSimple", "[formatter]") {
|
TEST_CASE("Formatter: AppCustomizeSimple", "[formatter]") {
|
||||||
@ -159,7 +159,7 @@ TEST_CASE("Formatter: AppCustomizeSimple", "[formatter]") {
|
|||||||
" -h,--help Print this help message and exit\n\n"
|
" -h,--help Print this help message and exit\n\n"
|
||||||
"Subcommands:\n"
|
"Subcommands:\n"
|
||||||
" subcom1 This\n"
|
" subcom1 This\n"
|
||||||
" subcom2 This\n\n");
|
" subcom2 This\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Formatter: AllSub", "[formatter]") {
|
TEST_CASE("Formatter: AllSub", "[formatter]") {
|
||||||
|
@ -813,7 +813,7 @@ TEST_CASE_METHOD(CapturedHelp, "CallForAllHelpOutput", "[help]") {
|
|||||||
" One description\n\n"
|
" One description\n\n"
|
||||||
"two\n"
|
"two\n"
|
||||||
" Options:\n"
|
" Options:\n"
|
||||||
" --three \n\n\n");
|
" --three \n\n");
|
||||||
}
|
}
|
||||||
TEST_CASE_METHOD(CapturedHelp, "NewFormattedHelp", "[help]") {
|
TEST_CASE_METHOD(CapturedHelp, "NewFormattedHelp", "[help]") {
|
||||||
app.formatter_fn([](const CLI::App *, std::string, CLI::AppFormatMode) { return "New Help"; });
|
app.formatter_fn([](const CLI::App *, std::string, CLI::AppFormatMode) { return "New Help"; });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user