UE: Use Vector<String> for the command-line arguments

Core::ArgsParser gained support for String a while ago. So let's use
that.
This commit is contained in:
Gunnar Beutner 2021-05-17 14:41:59 +02:00 committed by Andreas Kling
parent c2d9cd8d53
commit 26e711f953
Notes: sideshowbarker 2024-07-18 17:56:08 +09:00

View file

@ -19,27 +19,22 @@ bool g_report_to_debug = false;
int main(int argc, char** argv, char** env)
{
Vector<const char*> command;
Vector<String> arguments;
Core::ArgsParser parser;
parser.add_option(g_report_to_debug, "Write reports to the debug log", "report-to-debug", 0);
parser.add_positional_argument(command, "Command to emulate", "command");
parser.add_positional_argument(arguments, "Command to emulate", "command");
parser.parse(argc, argv);
auto executable_path = Core::find_executable_in_path(command[0]);
auto executable_path = Core::find_executable_in_path(arguments[0]);
if (executable_path.is_empty()) {
executable_path = Core::File::real_path_for(command[0]);
executable_path = Core::File::real_path_for(arguments[0]);
if (executable_path.is_empty()) {
reportln("Cannot find executable for '{}'.", executable_path);
return 1;
}
}
Vector<String> arguments;
for (auto arg : command) {
arguments.append(arg);
}
Vector<String> environment;
for (int i = 0; env[i]; ++i) {
environment.append(env[i]);