| 1181 | |
| 1182 | |
| 1183 | unsigned int cli_pre_detection(int argc, char* argv[]) |
| 1184 | { |
| 1185 | /*---------------------------------------------------------*\ |
| 1186 | | Process only the arguments that should be performed prior | |
| 1187 | | to detecting devices and/or starting clients | |
| 1188 | \*---------------------------------------------------------*/ |
| 1189 | int arg_index = 1; |
| 1190 | unsigned int cfg_args = 0; |
| 1191 | unsigned int ret_flags = 0; |
| 1192 | std::string server_host = OPENRGB_SDK_HOST; |
| 1193 | unsigned short server_port = OPENRGB_SDK_PORT; |
| 1194 | bool server_start = false; |
| 1195 | bool print_help = false; |
| 1196 | |
| 1197 | #ifdef _WIN32 |
| 1198 | int fake_argc; |
| 1199 | wchar_t** argvw = CommandLineToArgvW(GetCommandLineW(), &fake_argc); |
| 1200 | #endif |
| 1201 | |
| 1202 | while(arg_index < argc) |
| 1203 | { |
| 1204 | std::string option = argv[arg_index]; |
| 1205 | std::string argument = ""; |
| 1206 | |
| 1207 | LOG_DEBUG("Parsing CLI option: %s", option.c_str()); |
| 1208 | |
| 1209 | /*---------------------------------------------------------*\ |
| 1210 | | Handle options that take an argument | |
| 1211 | \*---------------------------------------------------------*/ |
| 1212 | if(arg_index + 1 < argc) |
| 1213 | { |
| 1214 | argument = argv[arg_index + 1]; |
| 1215 | } |
| 1216 | |
| 1217 | /*---------------------------------------------------------*\ |
| 1218 | | --localconfig | |
| 1219 | \*---------------------------------------------------------*/ |
| 1220 | if(option == "--localconfig") |
| 1221 | { |
| 1222 | ResourceManager::get()->SetConfigurationDirectory("./"); |
| 1223 | cfg_args++; |
| 1224 | } |
| 1225 | |
| 1226 | /*---------------------------------------------------------*\ |
| 1227 | | --config | |
| 1228 | \*---------------------------------------------------------*/ |
| 1229 | else if(option == "--config") |
| 1230 | { |
| 1231 | cfg_args+= 2; |
| 1232 | arg_index++; |
| 1233 | #ifdef _WIN32 |
| 1234 | filesystem::path config_path(argvw[arg_index]); |
| 1235 | #else |
| 1236 | filesystem::path config_path(argument); |
| 1237 | #endif |
| 1238 | |
| 1239 | if(filesystem::is_directory(config_path)) |
| 1240 | { |
no test coverage detected