1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 06:18:12 +00:00

Userland: Use Core::ArgsParser for 'which'

This commit is contained in:
Linus Groh 2020-08-05 19:39:42 +02:00 committed by Andreas Kling
parent cf81d9765c
commit 4ba23745c0

View file

@ -26,6 +26,7 @@
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
#include <stdio.h>
#include <unistd.h>
@ -36,12 +37,11 @@ int main(int argc, char** argv)
return 1;
}
if (argc < 2) {
printf("usage: which <executable>\n");
return 0;
}
const char* filename = nullptr;
char* filename = argv[1];
Core::ArgsParser args_parser;
args_parser.add_positional_argument(filename, "Name of executable", "executable");
args_parser.parse(argc, argv);
String path = getenv("PATH");
if (path.is_empty())