diff options
Diffstat (limited to 'src/yuzu_cmd/yuzu.cpp')
| -rw-r--r-- | src/yuzu_cmd/yuzu.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 8198cde16..14bf82f39 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp | |||
| @@ -62,7 +62,8 @@ static void PrintHelp(const char* argv0) { | |||
| 62 | "-f, --fullscreen Start in fullscreen mode\n" | 62 | "-f, --fullscreen Start in fullscreen mode\n" |
| 63 | "-h, --help Display this help and exit\n" | 63 | "-h, --help Display this help and exit\n" |
| 64 | "-v, --version Output version information and exit\n" | 64 | "-v, --version Output version information and exit\n" |
| 65 | "-p, --program Pass following string as arguments to executable\n"; | 65 | "-p, --program Pass following string as arguments to executable\n" |
| 66 | "-c, --config Load the specified configuration file\n"; | ||
| 66 | } | 67 | } |
| 67 | 68 | ||
| 68 | static void PrintVersion() { | 69 | static void PrintVersion() { |
| @@ -74,7 +75,6 @@ int main(int argc, char** argv) { | |||
| 74 | Common::Log::Initialize(); | 75 | Common::Log::Initialize(); |
| 75 | Common::Log::SetColorConsoleBackendEnabled(true); | 76 | Common::Log::SetColorConsoleBackendEnabled(true); |
| 76 | Common::DetachedTasks detached_tasks; | 77 | Common::DetachedTasks detached_tasks; |
| 77 | Config config; | ||
| 78 | 78 | ||
| 79 | int option_index = 0; | 79 | int option_index = 0; |
| 80 | #ifdef _WIN32 | 80 | #ifdef _WIN32 |
| @@ -87,19 +87,24 @@ int main(int argc, char** argv) { | |||
| 87 | } | 87 | } |
| 88 | #endif | 88 | #endif |
| 89 | std::string filepath; | 89 | std::string filepath; |
| 90 | std::optional<std::string> config_path; | ||
| 91 | std::string program_args; | ||
| 90 | 92 | ||
| 91 | bool fullscreen = false; | 93 | bool fullscreen = false; |
| 92 | 94 | ||
| 93 | static struct option long_options[] = { | 95 | static struct option long_options[] = { |
| 96 | // clang-format off | ||
| 94 | {"fullscreen", no_argument, 0, 'f'}, | 97 | {"fullscreen", no_argument, 0, 'f'}, |
| 95 | {"help", no_argument, 0, 'h'}, | 98 | {"help", no_argument, 0, 'h'}, |
| 96 | {"version", no_argument, 0, 'v'}, | 99 | {"version", no_argument, 0, 'v'}, |
| 97 | {"program", optional_argument, 0, 'p'}, | 100 | {"program", optional_argument, 0, 'p'}, |
| 101 | {"config", required_argument, 0, 'c'}, | ||
| 98 | {0, 0, 0, 0}, | 102 | {0, 0, 0, 0}, |
| 103 | // clang-format on | ||
| 99 | }; | 104 | }; |
| 100 | 105 | ||
| 101 | while (optind < argc) { | 106 | while (optind < argc) { |
| 102 | int arg = getopt_long(argc, argv, "g:fhvp::", long_options, &option_index); | 107 | int arg = getopt_long(argc, argv, "g:fhvp::c:", long_options, &option_index); |
| 103 | if (arg != -1) { | 108 | if (arg != -1) { |
| 104 | switch (static_cast<char>(arg)) { | 109 | switch (static_cast<char>(arg)) { |
| 105 | case 'f': | 110 | case 'f': |
| @@ -113,9 +118,12 @@ int main(int argc, char** argv) { | |||
| 113 | PrintVersion(); | 118 | PrintVersion(); |
| 114 | return 0; | 119 | return 0; |
| 115 | case 'p': | 120 | case 'p': |
| 116 | Settings::values.program_args = argv[optind]; | 121 | program_args = argv[optind]; |
| 117 | ++optind; | 122 | ++optind; |
| 118 | break; | 123 | break; |
| 124 | case 'c': | ||
| 125 | config_path = optarg; | ||
| 126 | break; | ||
| 119 | } | 127 | } |
| 120 | } else { | 128 | } else { |
| 121 | #ifdef _WIN32 | 129 | #ifdef _WIN32 |
| @@ -127,6 +135,12 @@ int main(int argc, char** argv) { | |||
| 127 | } | 135 | } |
| 128 | } | 136 | } |
| 129 | 137 | ||
| 138 | Config config{config_path}; | ||
| 139 | |||
| 140 | if (!program_args.empty()) { | ||
| 141 | Settings::values.program_args = program_args; | ||
| 142 | } | ||
| 143 | |||
| 130 | #ifdef _WIN32 | 144 | #ifdef _WIN32 |
| 131 | LocalFree(argv_w); | 145 | LocalFree(argv_w); |
| 132 | #endif | 146 | #endif |