summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-26 22:09:09 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-26 23:27:57 +0100
commit395ba619d8b0a5ac38368991a9da445cfb0e03a9 (patch)
tree7c01be7d107e7a7f85d39cf10cf7d5ce59363f63 /Userland/Libraries/LibCore
parent5bf6503ed1d3f4ff905630dbc242118ec00401f8 (diff)
downloadserenity-395ba619d8b0a5ac38368991a9da445cfb0e03a9.zip
LibCore: Add Vector<StringView> variant of add_positional_argument()
Diffstat (limited to 'Userland/Libraries/LibCore')
-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 2988189906..db1ec8d5e7 100644
--- a/Userland/Libraries/LibCore/ArgsParser.cpp
+++ b/Userland/Libraries/LibCore/ArgsParser.cpp
@@ -595,4 +595,19 @@ void ArgsParser::add_positional_argument(Vector<String>& values, const char* hel
add_positional_argument(move(arg));
}
+void ArgsParser::add_positional_argument(Vector<StringView>& 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));
+}
+
}
diff --git a/Userland/Libraries/LibCore/ArgsParser.h b/Userland/Libraries/LibCore/ArgsParser.h
index 538e3f9d59..9c0998968b 100644
--- a/Userland/Libraries/LibCore/ArgsParser.h
+++ b/Userland/Libraries/LibCore/ArgsParser.h
@@ -87,6 +87,7 @@ public:
void add_positional_argument(double& value, const char* help_string, const char* name, Required required = Required::Yes);
void add_positional_argument(Vector<const char*>& value, const char* help_string, const char* name, Required required = Required::Yes);
void add_positional_argument(Vector<String>& value, const char* help_string, const char* name, Required required = Required::Yes);
+ void add_positional_argument(Vector<StringView>& value, char const* help_string, char const* name, Required required = Required::Yes);
private:
Vector<Option> m_options;