mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +00:00
LibCore+Base: Hide empty options sections in manpages
This commit is contained in:
parent
cbc89632b9
commit
8214a935ab
2 changed files with 13 additions and 5 deletions
|
@ -12,9 +12,6 @@ $ fortune [path]
|
||||||
|
|
||||||
Open a fortune cookie, receive a free quote for the day!
|
Open a fortune cookie, receive a free quote for the day!
|
||||||
|
|
||||||
## Options:
|
|
||||||
|
|
||||||
|
|
||||||
## Arguments:
|
## Arguments:
|
||||||
|
|
||||||
* `path`: Path to JSON file with quotes (/res/fortunes.json by default)
|
* `path`: Path to JSON file with quotes (/res/fortunes.json by default)
|
||||||
|
|
|
@ -299,10 +299,21 @@ void ArgsParser::print_usage_markdown(FILE* file, char const* argv0)
|
||||||
outln(file, "\n## Description\n\n{}", m_general_help);
|
outln(file, "\n## Description\n\n{}", m_general_help);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_options.is_empty())
|
auto should_display_option = [](Option& opt) {
|
||||||
|
return !(opt.hide_mode == OptionHideMode::Markdown || opt.hide_mode == OptionHideMode::CommandLineAndMarkdown);
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t options_to_display = 0;
|
||||||
|
for (auto& opt : m_options) {
|
||||||
|
if (!should_display_option(opt))
|
||||||
|
continue;
|
||||||
|
options_to_display++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options_to_display > 0)
|
||||||
outln(file, "\n## Options:\n");
|
outln(file, "\n## Options:\n");
|
||||||
for (auto& opt : m_options) {
|
for (auto& opt : m_options) {
|
||||||
if (opt.hide_mode == OptionHideMode::Markdown || opt.hide_mode == OptionHideMode::CommandLineAndMarkdown)
|
if (!should_display_option(opt))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto print_argument = [&]() {
|
auto print_argument = [&]() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue