mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +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
|
@ -31,6 +31,11 @@ using Test::Crash;
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
Vector<StringView> arguments;
|
||||
arguments.ensure_capacity(argc);
|
||||
for (auto i = 0; i < argc; ++i)
|
||||
arguments.append({ argv[i], strlen(argv[i]) });
|
||||
|
||||
bool do_all_crash_types = false;
|
||||
bool do_segmentation_violation = false;
|
||||
bool do_division_by_zero = false;
|
||||
|
@ -84,11 +89,11 @@ int main(int argc, char** argv)
|
|||
if (argc == 1) {
|
||||
do_all_crash_types = true;
|
||||
} else if (argc != 2) {
|
||||
args_parser.print_usage(stderr, argv[0]);
|
||||
args_parser.print_usage(stderr, arguments[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
args_parser.parse(argc, argv);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
Crash::RunType run_type = do_all_crash_types ? Crash::RunType::UsingChildProcess
|
||||
: Crash::RunType::UsingCurrentProcess;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue