mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 13:30:31 +00:00
ArgsParser: Add support for Optional<size_t>
This commit is contained in:
parent
beb29c48cb
commit
24da85d059
Notes:
sideshowbarker
2024-07-17 18:38:12 +09:00
Author: https://github.com/brapru Commit: https://github.com/SerenityOS/serenity/commit/24da85d059 Pull-request: https://github.com/SerenityOS/serenity/pull/12567 Issue: https://github.com/SerenityOS/serenity/issues/12524 Reviewed-by: https://github.com/davidot Reviewed-by: https://github.com/trflynn89 ✅
2 changed files with 17 additions and 0 deletions
|
@ -484,6 +484,22 @@ void ArgsParser::add_option(Optional<double>& value, const char* help_string, co
|
|||
add_option(move(option));
|
||||
}
|
||||
|
||||
void ArgsParser::add_option(Optional<size_t>& value, const char* help_string, const char* long_name, char short_name, const char* value_name)
|
||||
{
|
||||
Option option {
|
||||
true,
|
||||
help_string,
|
||||
long_name,
|
||||
short_name,
|
||||
value_name,
|
||||
[&value](const char* s) {
|
||||
value = AK::StringUtils::convert_to_uint<size_t>(s);
|
||||
return value.has_value();
|
||||
}
|
||||
};
|
||||
add_option(move(option));
|
||||
}
|
||||
|
||||
void ArgsParser::add_positional_argument(Arg&& arg)
|
||||
{
|
||||
m_positional_args.append(move(arg));
|
||||
|
|
|
@ -78,6 +78,7 @@ public:
|
|||
void add_option(unsigned& value, const char* help_string, const char* long_name, char short_name, const char* value_name);
|
||||
void add_option(double& value, const char* help_string, const char* long_name, char short_name, const char* value_name);
|
||||
void add_option(Optional<double>& value, const char* help_string, const char* long_name, char short_name, const char* value_name);
|
||||
void add_option(Optional<size_t>& value, const char* help_string, const char* long_name, char short_name, const char* value_name);
|
||||
|
||||
void add_positional_argument(Arg&&);
|
||||
void add_positional_argument(const char*& value, const char* help_string, const char* name, Required required = Required::Yes);
|
||||
|
|
Loading…
Reference in a new issue