mirror of
https://github.com/CLIUtils/CLI11.git
synced 2026-01-19 04:52:08 +00:00
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>
This commit is contained in:
1
.github/workflows/tests.yml
vendored
1
.github/workflows/tests.yml
vendored
@@ -60,7 +60,6 @@ jobs:
|
||||
- uses: codecov/codecov-action@v5
|
||||
with:
|
||||
files: build/coverage.info
|
||||
functionalities: fixes
|
||||
|
||||
preset:
|
||||
name: Preset
|
||||
|
||||
29
README.md
29
README.md
@@ -504,26 +504,25 @@ Before parsing, you can set the following options:
|
||||
parsed vs. at the end of all parsing. This could cause the callback to be
|
||||
executed multiple times. Also works with positional options.
|
||||
- `->callback_priority(CallbackPriority priority)`: 🚧 changes the order in
|
||||
which the option callback is executed. Four principal callback call-points
|
||||
are available. `CallbackPriority::First` executes at the very beginning of
|
||||
which the option callback is executed. Four principal callback call-points are
|
||||
available. `CallbackPriority::First` executes at the very beginning of
|
||||
processing, before configuration files are read and environment variables are
|
||||
interpreted. `CallbackPriority::PreRequirementsCheck` executes after
|
||||
configuration and environment processing but before requirements checking.
|
||||
`CallbackPriority::Normal` executes after the requirements check but before
|
||||
any previously potentially raised exceptions are re-thrown.
|
||||
`CallbackPriority::Last` executes after exception handling is completed.
|
||||
For each position, both ordinary option callbacks and help callbacks are
|
||||
invoked. The relative order between them can be controlled using the
|
||||
corresponding `PreHelp` variants. `CallbackPriority::FirstPreHelp` executes
|
||||
ordinary option callbacks before help callbacks at the very beginning of
|
||||
processing. `CallbackPriority::PreRequirementsCheckPreHelp` executes ordinary
|
||||
option callbacks before help callbacks after configuration and environment
|
||||
processing but before requirements checking. `CallbackPriority::NormalPreHelp`
|
||||
executes ordinary option callbacks before help callbacks after the
|
||||
requirements check but before exception re-throwing.
|
||||
`CallbackPriority::LastPreHelp` executes ordinary option callbacks before help
|
||||
callbacks after exception handling has completed. When using the standard
|
||||
priorities (`CallbackPriority::First`,
|
||||
`CallbackPriority::Last` executes after exception handling is completed. For
|
||||
each position, both ordinary option callbacks and help callbacks are invoked.
|
||||
The relative order between them can be controlled using the corresponding
|
||||
`PreHelp` variants. `CallbackPriority::FirstPreHelp` executes ordinary option
|
||||
callbacks before help callbacks at the very beginning of processing.
|
||||
`CallbackPriority::PreRequirementsCheckPreHelp` executes ordinary option
|
||||
callbacks before help callbacks after configuration and environment processing
|
||||
but before requirements checking. `CallbackPriority::NormalPreHelp` executes
|
||||
ordinary option callbacks before help callbacks after the requirements check
|
||||
but before exception re-throwing. `CallbackPriority::LastPreHelp` executes
|
||||
ordinary option callbacks before help callbacks after exception handling has
|
||||
completed. When using the standard priorities (`CallbackPriority::First`,
|
||||
`CallbackPriority::PreRequirementsCheck`, `CallbackPriority::Normal`,
|
||||
`CallbackPriority::Last`), help callbacks are executed before ordinary option
|
||||
callbacks. By default, help callbacks use `CallbackPriority::First`, and
|
||||
|
||||
@@ -147,7 +147,7 @@ CLI11_INLINE std::string Formatter::make_footer(const App *app) const {
|
||||
if(footer.empty()) {
|
||||
return std::string{};
|
||||
}
|
||||
return '\n' + footer + "\n\n";
|
||||
return '\n' + footer + '\n';
|
||||
}
|
||||
|
||||
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
|
||||
footer_string = "";
|
||||
}
|
||||
}
|
||||
if(is_footer_paragraph_formatting_enabled()) {
|
||||
detail::streamOutAsParagraph(out, footer_string, footer_paragraph_width_); // Format footer as paragraph
|
||||
} else {
|
||||
out << footer_string << '\n';
|
||||
if(!footer_string.empty()) {
|
||||
if(is_footer_paragraph_formatting_enabled()) {
|
||||
detail::streamOutAsParagraph(out, footer_string, footer_paragraph_width_); // Format footer as paragraph
|
||||
} else {
|
||||
out << footer_string;
|
||||
}
|
||||
}
|
||||
out << '\n';
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user