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 b44ea0cc4..f6d563017 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp | |||
| @@ -66,7 +66,8 @@ static void PrintHelp(const char* argv0) { | |||
| 66 | "-f, --fullscreen Start in fullscreen mode\n" | 66 | "-f, --fullscreen Start in fullscreen mode\n" |
| 67 | "-h, --help Display this help and exit\n" | 67 | "-h, --help Display this help and exit\n" |
| 68 | "-v, --version Output version information and exit\n" | 68 | "-v, --version Output version information and exit\n" |
| 69 | "-p, --program Pass following string as arguments to executable\n"; | 69 | "-p, --program Pass following string as arguments to executable\n" |
| 70 | "-c, --config Load the specified configuration file\n"; | ||
| 70 | } | 71 | } |
| 71 | 72 | ||
| 72 | static void PrintVersion() { | 73 | static void PrintVersion() { |
| @@ -78,7 +79,6 @@ int main(int argc, char** argv) { | |||
| 78 | Common::Log::Initialize(); | 79 | Common::Log::Initialize(); |
| 79 | Common::Log::SetColorConsoleBackendEnabled(true); | 80 | Common::Log::SetColorConsoleBackendEnabled(true); |
| 80 | Common::DetachedTasks detached_tasks; | 81 | Common::DetachedTasks detached_tasks; |
| 81 | Config config; | ||
| 82 | 82 | ||
| 83 | int option_index = 0; | 83 | int option_index = 0; |
| 84 | #ifdef _WIN32 | 84 | #ifdef _WIN32 |
| @@ -91,19 +91,24 @@ int main(int argc, char** argv) { | |||
| 91 | } | 91 | } |
| 92 | #endif | 92 | #endif |
| 93 | std::string filepath; | 93 | std::string filepath; |
| 94 | std::optional<std::string> config_path; | ||
| 95 | std::string program_args; | ||
| 94 | 96 | ||
| 95 | bool fullscreen = false; | 97 | bool fullscreen = false; |
| 96 | 98 | ||
| 97 | static struct option long_options[] = { | 99 | static struct option long_options[] = { |
| 100 | // clang-format off | ||
| 98 | {"fullscreen", no_argument, 0, 'f'}, | 101 | {"fullscreen", no_argument, 0, 'f'}, |
| 99 | {"help", no_argument, 0, 'h'}, | 102 | {"help", no_argument, 0, 'h'}, |
| 100 | {"version", no_argument, 0, 'v'}, | 103 | {"version", no_argument, 0, 'v'}, |
| 101 | {"program", optional_argument, 0, 'p'}, | 104 | {"program", optional_argument, 0, 'p'}, |
| 105 | {"config", required_argument, 0, 'c'}, | ||
| 102 | {0, 0, 0, 0}, | 106 | {0, 0, 0, 0}, |
| 107 | // clang-format on | ||
| 103 | }; | 108 | }; |
| 104 | 109 | ||
| 105 | while (optind < argc) { | 110 | while (optind < argc) { |
| 106 | int arg = getopt_long(argc, argv, "g:fhvp::", long_options, &option_index); | 111 | int arg = getopt_long(argc, argv, "g:fhvp::c:", long_options, &option_index); |
| 107 | if (arg != -1) { | 112 | if (arg != -1) { |
| 108 | switch (static_cast<char>(arg)) { | 113 | switch (static_cast<char>(arg)) { |
| 109 | case 'f': | 114 | case 'f': |
| @@ -117,9 +122,12 @@ int main(int argc, char** argv) { | |||
| 117 | PrintVersion(); | 122 | PrintVersion(); |
| 118 | return 0; | 123 | return 0; |
| 119 | case 'p': | 124 | case 'p': |
| 120 | Settings::values.program_args = argv[optind]; | 125 | program_args = argv[optind]; |
| 121 | ++optind; | 126 | ++optind; |
| 122 | break; | 127 | break; |
| 128 | case 'c': | ||
| 129 | config_path = optarg; | ||
| 130 | break; | ||
| 123 | } | 131 | } |
| 124 | } else { | 132 | } else { |
| 125 | #ifdef _WIN32 | 133 | #ifdef _WIN32 |
| @@ -131,6 +139,12 @@ int main(int argc, char** argv) { | |||
| 131 | } | 139 | } |
| 132 | } | 140 | } |
| 133 | 141 | ||
| 142 | Config config{config_path}; | ||
| 143 | |||
| 144 | if (!program_args.empty()) { | ||
| 145 | Settings::values.program_args = program_args; | ||
| 146 | } | ||
| 147 | |||
| 134 | #ifdef _WIN32 | 148 | #ifdef _WIN32 |
| 135 | LocalFree(argv_w); | 149 | LocalFree(argv_w); |
| 136 | #endif | 150 | #endif |