mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-31 14:48:17 +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
Notes:
sideshowbarker
2024-07-17 22:55:25 +09:00
Author: https://github.com/alimpfard
Commit: db886fe18b
Pull-request: https://github.com/SerenityOS/serenity/pull/17538
Reviewed-by: https://github.com/ADKaster
43 changed files with 673 additions and 584 deletions
|
@ -111,19 +111,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
if (!transform_flag && !delete_flag && !squeeze_flag) {
|
||||
warnln("tr: Missing operand");
|
||||
args_parser.print_usage(stderr, arguments.argv[0]);
|
||||
args_parser.print_usage(stderr, arguments.strings[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (delete_flag && squeeze_flag && to_chars.is_empty()) {
|
||||
warnln("tr: Combined delete and squeeze operations need two sets of characters");
|
||||
args_parser.print_usage(stderr, arguments.argv[0]);
|
||||
args_parser.print_usage(stderr, arguments.strings[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (delete_flag && !squeeze_flag && !to_chars.is_empty()) {
|
||||
warnln("tr: Only one set of characters may be given when deleting without squeezing");
|
||||
args_parser.print_usage(stderr, arguments.argv[0]);
|
||||
args_parser.print_usage(stderr, arguments.strings[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue