1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:17:44 +00:00

Userland+Terminal: Port to new CArgsParser API

While at it, also add some niceties and fix some things.
This commit is contained in:
Sergey Bugaev 2020-01-27 20:25:36 +03:00 committed by Andreas Kling
parent 9276582535
commit f983dfe319
22 changed files with 392 additions and 653 deletions

View file

@ -30,17 +30,19 @@
int main(int argc, char** argv)
{
CArgsParser args_parser("shutdown");
args_parser.add_arg("n", "shut down now");
CArgsParserResult args = args_parser.parse(argc, argv);
bool now = false;
if (args.is_present("n")) {
CArgsParser args_parser;
args_parser.add_option(now, "Shut down now", "now", 'n');
args_parser.parse(argc, argv);
if (now) {
if (halt() < 0) {
perror("shutdown");
return 1;
}
} else {
args_parser.print_usage();
return 0;
args_parser.print_usage(stderr, argv[0]);
return 1;
}
}