Skip to content

Commit 3388e8e

Browse files
Help spacing (#1229)
Fix the help spacing and double printing of footers in certain circumstances --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 0104dce commit 3388e8e

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ jobs:
6060
- uses: codecov/codecov-action@v5
6161
with:
6262
files: build/coverage.info
63-
functionalities: fixes
6463

6564
preset:
6665
name: Preset

README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -504,26 +504,25 @@ Before parsing, you can set the following options:
504504
parsed vs. at the end of all parsing. This could cause the callback to be
505505
executed multiple times. Also works with positional options.
506506
- `->callback_priority(CallbackPriority priority)`: 🚧 changes the order in
507-
which the option callback is executed. Four principal callback call-points
508-
are available. `CallbackPriority::First` executes at the very beginning of
507+
which the option callback is executed. Four principal callback call-points are
508+
available. `CallbackPriority::First` executes at the very beginning of
509509
processing, before configuration files are read and environment variables are
510510
interpreted. `CallbackPriority::PreRequirementsCheck` executes after
511511
configuration and environment processing but before requirements checking.
512512
`CallbackPriority::Normal` executes after the requirements check but before
513513
any previously potentially raised exceptions are re-thrown.
514-
`CallbackPriority::Last` executes after exception handling is completed.
515-
For each position, both ordinary option callbacks and help callbacks are
516-
invoked. The relative order between them can be controlled using the
517-
corresponding `PreHelp` variants. `CallbackPriority::FirstPreHelp` executes
518-
ordinary option callbacks before help callbacks at the very beginning of
519-
processing. `CallbackPriority::PreRequirementsCheckPreHelp` executes ordinary
520-
option callbacks before help callbacks after configuration and environment
521-
processing but before requirements checking. `CallbackPriority::NormalPreHelp`
522-
executes ordinary option callbacks before help callbacks after the
523-
requirements check but before exception re-throwing.
524-
`CallbackPriority::LastPreHelp` executes ordinary option callbacks before help
525-
callbacks after exception handling has completed. When using the standard
526-
priorities (`CallbackPriority::First`,
514+
`CallbackPriority::Last` executes after exception handling is completed. For
515+
each position, both ordinary option callbacks and help callbacks are invoked.
516+
The relative order between them can be controlled using the corresponding
517+
`PreHelp` variants. `CallbackPriority::FirstPreHelp` executes ordinary option
518+
callbacks before help callbacks at the very beginning of processing.
519+
`CallbackPriority::PreRequirementsCheckPreHelp` executes ordinary option
520+
callbacks before help callbacks after configuration and environment processing
521+
but before requirements checking. `CallbackPriority::NormalPreHelp` executes
522+
ordinary option callbacks before help callbacks after the requirements check
523+
but before exception re-throwing. `CallbackPriority::LastPreHelp` executes
524+
ordinary option callbacks before help callbacks after exception handling has
525+
completed. When using the standard priorities (`CallbackPriority::First`,
527526
`CallbackPriority::PreRequirementsCheck`, `CallbackPriority::Normal`,
528527
`CallbackPriority::Last`), help callbacks are executed before ordinary option
529528
callbacks. By default, help callbacks use `CallbackPriority::First`, and

include/CLI/impl/Formatter_inl.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ CLI11_INLINE std::string Formatter::make_footer(const App *app) const {
147147
if(footer.empty()) {
148148
return std::string{};
149149
}
150-
return '\n' + footer + "\n\n";
150+
return '\n' + footer + '\n';
151151
}
152152

153153
CLI11_INLINE std::string Formatter::make_help(const App *app, std::string name, AppFormatMode mode) const {
@@ -263,12 +263,13 @@ CLI11_INLINE std::string Formatter::make_expanded(const App *sub, AppFormatMode
263263
footer_string = "";
264264
}
265265
}
266-
if(is_footer_paragraph_formatting_enabled()) {
267-
detail::streamOutAsParagraph(out, footer_string, footer_paragraph_width_); // Format footer as paragraph
268-
} else {
269-
out << footer_string << '\n';
266+
if(!footer_string.empty()) {
267+
if(is_footer_paragraph_formatting_enabled()) {
268+
detail::streamOutAsParagraph(out, footer_string, footer_paragraph_width_); // Format footer as paragraph
269+
} else {
270+
out << footer_string;
271+
}
270272
}
271-
out << '\n';
272273
return out.str();
273274
}
274275

0 commit comments

Comments
 (0)