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:
parent
d64d2e4d09
commit
63a846a2ac
2 changed files with 16 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue