mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +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
|
@ -83,7 +83,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
.long_name = "regexp",
|
||||
.short_name = 'e',
|
||||
.value_name = "Pattern",
|
||||
.accept_value = [&](auto* str) {
|
||||
.accept_value = [&](StringView str) {
|
||||
patterns.append(str);
|
||||
return true;
|
||||
},
|
||||
|
@ -97,7 +97,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
|
||||
.help_string = "Action to take for binary files ([binary], text, skip)",
|
||||
.long_name = "binary-mode",
|
||||
.accept_value = [&](auto* str) {
|
||||
.accept_value = [&](StringView str) {
|
||||
if ("text"sv == str)
|
||||
binary_mode = BinaryFileMode::Text;
|
||||
else if ("binary"sv == str)
|
||||
|
@ -135,7 +135,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
.long_name = "color",
|
||||
.short_name = 0,
|
||||
.value_name = "WHEN",
|
||||
.accept_value = [&](auto* str) {
|
||||
.accept_value = [&](StringView str) {
|
||||
if ("never"sv == str)
|
||||
colored_output = false;
|
||||
else if ("always"sv == str)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue