mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 05:55:13 +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 <AK/LexicalPath.h>
|
||||||
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
@ -34,10 +35,12 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc != 2) {
|
const char* path = nullptr;
|
||||||
printf("usage: basename <path>\n");
|
|
||||||
return 1;
|
Core::ArgsParser args_parser;
|
||||||
}
|
args_parser.add_positional_argument(path, "Path to get basename from", "path");
|
||||||
printf("%s\n", LexicalPath(argv[1]).basename().characters());
|
args_parser.parse(argc, argv);
|
||||||
|
|
||||||
|
printf("%s\n", LexicalPath(path).basename().characters());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue