summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore/ArgsParser.cpp
diff options
context:
space:
mode:
authorspeles <speles@mail.ua>2021-03-05 21:38:06 +0200
committerAndreas Kling <kling@serenityos.org>2021-03-07 11:00:36 +0100
commit63a846a2ac63e9e8583b908c0d78298fc56b12e5 (patch)
tree6193e9cece5d459f9cd039c0b5d111fc8617797e /Userland/Libraries/LibCore/ArgsParser.cpp
parentd64d2e4d09ecd343e07b9f066a0185578bd8eb48 (diff)
downloadserenity-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.cpp15
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 {