1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:28:11 +00:00

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.
This commit is contained in:
speles 2021-03-05 21:38:06 +02:00 committed by Andreas Kling
parent d64d2e4d09
commit 63a846a2ac
2 changed files with 16 additions and 0 deletions

View file

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