diff options
author | sin-ack <sin-ack@users.noreply.github.com> | 2022-07-11 19:59:54 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-12 23:11:35 +0200 |
commit | 6eecc65787abd1dcbbff157e0c3be73b03a4c225 (patch) | |
tree | 3b38f5426eb14aaf6e27ee611d9cf10cd7b62b78 /Userland | |
parent | 52d017c61121dd6fcfbf31c274a83da126271252 (diff) | |
download | serenity-6eecc65787abd1dcbbff157e0c3be73b03a4c225.zip |
AK: Explicitly calculate length of char* when printing
This moves out the calculation of the char* out to the formatter.
Additionally, we now print (null) when a null pointer is passed.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibCore/ArgsParser.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Libraries/LibCore/ArgsParser.cpp b/Userland/Libraries/LibCore/ArgsParser.cpp index 021e83924f..ead8ed0925 100644 --- a/Userland/Libraries/LibCore/ArgsParser.cpp +++ b/Userland/Libraries/LibCore/ArgsParser.cpp @@ -275,8 +275,12 @@ void ArgsParser::print_usage_markdown(FILE* file, char const* argv0) for (auto& opt : m_options) { if (opt.hide_mode != OptionHideMode::None) continue; + + // FIXME: We allow opt.value_name to be empty even if the option + // requires an argument. This should be disallowed as it will + // currently display a blank name after the option. if (opt.requires_argument) - out(file, " [{} {}]", opt.name_for_display(), opt.value_name); + out(file, " [{} {}]", opt.name_for_display(), opt.value_name ?: ""); else out(file, " [{}]", opt.name_for_display()); } |