mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:37:45 +00:00
Userland+AK: Stop using getopt() for ArgsParser
This commit moves the implementation of getopt into AK, and converts its API to understand and use StringView instead of char*. Everything else is caught in the crossfire of making Option::accept_value() take a StringView instead of a char const*. With this, we must now pass a Span<StringView> to ArgsParser::parse(), applications using LibMain are unaffected, but anything not using that or taking its own argc/argv has to construct a Vector<StringView> for this method.
This commit is contained in:
parent
b2b851b361
commit
db886fe18b
43 changed files with 673 additions and 584 deletions
|
@ -66,8 +66,7 @@ ErrorOr<void> parse_args(Main::Arguments arguments, Vector<DeprecatedString>& fi
|
|||
"time",
|
||||
0,
|
||||
"time-type",
|
||||
[&du_option](auto const* option_ptr) {
|
||||
StringView option { option_ptr, strlen(option_ptr) };
|
||||
[&du_option](StringView option) {
|
||||
if (option == "mtime"sv || option == "modification"sv)
|
||||
du_option.time_type = DuOption::TimeType::Modification;
|
||||
else if (option == "ctime"sv || option == "status"sv || option == "use"sv)
|
||||
|
@ -87,7 +86,7 @@ ErrorOr<void> parse_args(Main::Arguments arguments, Vector<DeprecatedString>& fi
|
|||
nullptr,
|
||||
'k',
|
||||
nullptr,
|
||||
[&du_option](auto const*) {
|
||||
[&du_option](StringView) {
|
||||
du_option.block_size = 1024;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue