diff options
author | speles <speles@mail.ua> | 2021-03-05 21:38:06 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-07 11:00:36 +0100 |
commit | 63a846a2ac63e9e8583b908c0d78298fc56b12e5 (patch) | |
tree | 6193e9cece5d459f9cd039c0b5d111fc8617797e /Userland/Libraries/LibCore/ArgsParser.cpp | |
parent | d64d2e4d09ecd343e07b9f066a0185578bd8eb48 (diff) | |
download | serenity-63a846a2ac63e9e8583b908c0d78298fc56b12e5.zip |
LibCore: Add String variant for ArgsParser::add_positional_argument
This is basically the same version as const char *, but it's a nice
helper that allows us to handle strings without casting.
Diffstat (limited to 'Userland/Libraries/LibCore/ArgsParser.cpp')
-rw-r--r-- | Userland/Libraries/LibCore/ArgsParser.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/ArgsParser.cpp b/Userland/Libraries/LibCore/ArgsParser.cpp index ae94b3a39e..c42a6d9579 100644 --- a/Userland/Libraries/LibCore/ArgsParser.cpp +++ b/Userland/Libraries/LibCore/ArgsParser.cpp @@ -342,6 +342,21 @@ void ArgsParser::add_positional_argument(const char*& value, const char* help_st add_positional_argument(move(arg)); } +void ArgsParser::add_positional_argument(String& value, const char* help_string, const char* name, Required required) +{ + Arg arg { + help_string, + name, + required == Required::Yes ? 1 : 0, + 1, + [&value](const char* s) { + value = s; + return true; + } + }; + add_positional_argument(move(arg)); +} + void ArgsParser::add_positional_argument(int& value, const char* help_string, const char* name, Required required) { Arg arg { |