summaryrefslogtreecommitdiff
path: root/Userland/basename.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-08-05 22:42:22 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-06 20:41:13 +0200
commit9b07defb369d9f1d6c258e238ea5da947b12f70c (patch)
tree11895f239701ee25ec8a1d40697873b355739617 /Userland/basename.cpp
parent14db94f44be766af786cdf05bff8edc82f8f9da5 (diff)
downloadserenity-9b07defb369d9f1d6c258e238ea5da947b12f70c.zip
Userland: Use Core::ArgsParser for 'basename'
Diffstat (limited to 'Userland/basename.cpp')
-rw-r--r--Userland/basename.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/Userland/basename.cpp b/Userland/basename.cpp
index 2d211340f0..65862f1072 100644
--- a/Userland/basename.cpp
+++ b/Userland/basename.cpp
@@ -25,6 +25,7 @@
*/
#include <AK/LexicalPath.h>
+#include <LibCore/ArgsParser.h>
#include <stdio.h>
int main(int argc, char** argv)
@@ -34,10 +35,12 @@ int main(int argc, char** argv)
return 1;
}
- if (argc != 2) {
- printf("usage: basename <path>\n");
- return 1;
- }
- printf("%s\n", LexicalPath(argv[1]).basename().characters());
+ const char* path = nullptr;
+
+ Core::ArgsParser args_parser;
+ args_parser.add_positional_argument(path, "Path to get basename from", "path");
+ args_parser.parse(argc, argv);
+
+ printf("%s\n", LexicalPath(path).basename().characters());
return 0;
}