mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +00:00
LibCore: Add add_option aggregating the same option multiple times
This could be used in a scenario when it is expected that a user program will be invoked with a specific option multiple times, for example: "program --a-option=example --a-option=anotherexample ..."
This commit is contained in:
parent
718ae68621
commit
7d7127b463
2 changed files with 22 additions and 0 deletions
|
@ -569,6 +569,25 @@ void ArgsParser::add_option(Vector<size_t>& values, char const* help_string, cha
|
|||
add_option(move(option));
|
||||
}
|
||||
|
||||
void ArgsParser::add_option(Vector<String>& values, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode)
|
||||
{
|
||||
Option option {
|
||||
OptionArgumentMode::Optional,
|
||||
help_string,
|
||||
long_name,
|
||||
short_name,
|
||||
value_name,
|
||||
[&values](char const* s) {
|
||||
String value = s;
|
||||
values.append(value);
|
||||
return true;
|
||||
},
|
||||
hide_mode
|
||||
};
|
||||
|
||||
add_option(move(option));
|
||||
}
|
||||
|
||||
void ArgsParser::add_positional_argument(Arg&& arg)
|
||||
{
|
||||
m_positional_args.append(move(arg));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue