LibCore: Add ArgsParser::add_positional_argument(Vector<String>&, ...)

This commit is contained in:
Sam Atkins 2022-04-02 15:32:51 +01:00 committed by Andreas Kling
parent b81a3a6f0e
commit 3e5b1b1dbc
Notes: sideshowbarker 2024-07-17 12:05:31 +09:00
2 changed files with 16 additions and 0 deletions

View file

@ -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 {

View file

@ -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: