From 4ba23745c03b511e7aa637afd8a56a63a63a5af0 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Wed, 5 Aug 2020 19:39:42 +0200 Subject: [PATCH] Userland: Use Core::ArgsParser for 'which' --- Userland/which.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Userland/which.cpp b/Userland/which.cpp index 67a9bb8106..7d58a12c6f 100644 --- a/Userland/which.cpp +++ b/Userland/which.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -36,12 +37,11 @@ int main(int argc, char** argv) return 1; } - if (argc < 2) { - printf("usage: which \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())