From 53f3313cee3c78a1ead8eace23b88b224c21c847 Mon Sep 17 00:00:00 2001 From: Maciej Zygmanowski Date: Thu, 24 Sep 2020 20:07:07 +0200 Subject: [PATCH] UserspaceEmulator: Use Core::ArgsParser --- DevTools/UserspaceEmulator/main.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/DevTools/UserspaceEmulator/main.cpp b/DevTools/UserspaceEmulator/main.cpp index 7d120ee768..330decd867 100644 --- a/DevTools/UserspaceEmulator/main.cpp +++ b/DevTools/UserspaceEmulator/main.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -38,12 +39,13 @@ int main(int argc, char** argv, char** env) { - if (argc == 1) { - out() << "Usage: UserspaceEmulator "; - return 0; - } + Vector command; - auto executable_path = Core::find_executable_in_path(argv[1]); + Core::ArgsParser parser; + parser.add_positional_argument(command, "Command to emulate", "command"); + parser.parse(argc, argv); + + auto executable_path = Core::find_executable_in_path(command[0]); MappedFile mapped_file(executable_path); if (!mapped_file.is_valid()) { @@ -54,8 +56,8 @@ int main(int argc, char** argv, char** env) auto elf = ELF::Loader::create((const u8*)mapped_file.data(), mapped_file.size()); Vector arguments; - for (int i = 1; i < argc; ++i) { - arguments.append(argv[i]); + for (auto arg: command) { + arguments.append(arg); } Vector environment;