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;