1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:07:35 +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:
Liav A 2022-11-04 20:47:36 +02:00 committed by Andrew Kaster
parent 718ae68621
commit 7d7127b463
2 changed files with 22 additions and 0 deletions

View file

@ -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));