mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
Userland: Use Core::ArgsParser for 'basename'
This commit is contained in:
parent
14db94f44b
commit
9b07defb36
Notes:
sideshowbarker
2024-07-19 04:11:16 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/9b07defb369 Pull-request: https://github.com/SerenityOS/serenity/pull/3019
1 changed files with 8 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue