summaryrefslogtreecommitdiff
path: root/Userland/shutdown.cpp
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@serenityos.org>2020-01-27 20:25:36 +0300
committerAndreas Kling <kling@serenityos.org>2020-01-28 13:50:18 +0100
commitf983dfe319978b47b4c5314df9ea3373e3d69c05 (patch)
tree27d599f2c30ca6bfbfee6fbc3df98a08f33ac887 /Userland/shutdown.cpp
parent92765825358daaed11fa105ca64cf2c7819e5563 (diff)
downloadserenity-f983dfe319978b47b4c5314df9ea3373e3d69c05.zip
Userland+Terminal: Port to new CArgsParser API
While at it, also add some niceties and fix some things.
Diffstat (limited to 'Userland/shutdown.cpp')
-rw-r--r--Userland/shutdown.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/Userland/shutdown.cpp b/Userland/shutdown.cpp
index 3ce7c71923..7dd7fecc57 100644
--- a/Userland/shutdown.cpp
+++ b/Userland/shutdown.cpp
@@ -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;
}
}