summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-04-02 15:32:51 +0100
committerAndreas Kling <kling@serenityos.org>2022-04-11 21:09:42 +0200
commit3e5b1b1dbc59fe1b018060bf1f1110fd254595ea (patch)
tree0000b846fe4dbd4342a1cf51cb7ae142c655f22f /Userland
parentb81a3a6f0ece026a2cb3ec62d28e0d3dd12aabd8 (diff)
downloadserenity-3e5b1b1dbc59fe1b018060bf1f1110fd254595ea.zip
LibCore: Add `ArgsParser::add_positional_argument(Vector<String>&, ...)`
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibCore/ArgsParser.cpp15
-rw-r--r--Userland/Libraries/LibCore/ArgsParser.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/ArgsParser.cpp b/Userland/Libraries/LibCore/ArgsParser.cpp
index 912e397d64..021e83924f 100644
--- a/Userland/Libraries/LibCore/ArgsParser.cpp
+++ b/Userland/Libraries/LibCore/ArgsParser.cpp
@@ -676,6 +676,21 @@ void ArgsParser::add_positional_argument(Vector<char const*>& values, char const
add_positional_argument(move(arg));
}
+void ArgsParser::add_positional_argument(Vector<String>& values, char const* help_string, char const* name, Required required)
+{
+ Arg arg {
+ help_string,
+ name,
+ required == Required::Yes ? 1 : 0,
+ INT_MAX,
+ [&values](char const* s) {
+ values.append(s);
+ return true;
+ }
+ };
+ add_positional_argument(move(arg));
+}
+
void ArgsParser::add_positional_argument(Vector<StringView>& values, char const* help_string, char const* name, Required required)
{
Arg arg {
diff --git a/Userland/Libraries/LibCore/ArgsParser.h b/Userland/Libraries/LibCore/ArgsParser.h
index cb0dca0841..5caaee33db 100644
--- a/Userland/Libraries/LibCore/ArgsParser.h
+++ b/Userland/Libraries/LibCore/ArgsParser.h
@@ -98,6 +98,7 @@ public:
void add_positional_argument(unsigned& value, char const* help_string, char const* name, Required required = Required::Yes);
void add_positional_argument(double& value, char const* help_string, char const* name, Required required = Required::Yes);
void add_positional_argument(Vector<char const*>& value, char const* help_string, char const* name, Required required = Required::Yes);
+ void add_positional_argument(Vector<String>& value, char const* help_string, char const* name, Required required = Required::Yes);
void add_positional_argument(Vector<StringView>& value, char const* help_string, char const* name, Required required = Required::Yes);
private: