From 3e5b1b1dbc59fe1b018060bf1f1110fd254595ea Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Sat, 2 Apr 2022 15:32:51 +0100 Subject: [PATCH] LibCore: Add `ArgsParser::add_positional_argument(Vector&, ...)` --- Userland/Libraries/LibCore/ArgsParser.cpp | 15 +++++++++++++++ Userland/Libraries/LibCore/ArgsParser.h | 1 + 2 files changed, 16 insertions(+) diff --git a/Userland/Libraries/LibCore/ArgsParser.cpp b/Userland/Libraries/LibCore/ArgsParser.cpp index 912e397d648..021e83924f0 100644 --- a/Userland/Libraries/LibCore/ArgsParser.cpp +++ b/Userland/Libraries/LibCore/ArgsParser.cpp @@ -676,6 +676,21 @@ void ArgsParser::add_positional_argument(Vector& values, char const add_positional_argument(move(arg)); } +void ArgsParser::add_positional_argument(Vector& 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& 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 cb0dca0841c..5caaee33db4 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& value, char const* help_string, char const* name, Required required = Required::Yes); + void add_positional_argument(Vector& value, char const* help_string, char const* name, Required required = Required::Yes); void add_positional_argument(Vector& value, char const* help_string, char const* name, Required required = Required::Yes); private: