mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-10-09 22:53:32 +00:00
[eden-cli] add extra CLI options -n/-x/-s (#4173)
from wasm PR: - `--null-render/-n`: Forces the usage of the "Null" render backend irrespective of settings. - `--filter/-x`: Sets the debug log filter irrespective of settings. - `--singlecore/-s`: Forces single-core regardless of settings. Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4173 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: Maufeat <sahyno1996@gmail.com>
This commit is contained in:
@@ -27,3 +27,6 @@ There are two main applications, an SDL-based app (`eden-cli`) and a Qt based ap
|
|||||||
- `--user/-u`: Specify the user index.
|
- `--user/-u`: Specify the user index.
|
||||||
- `--version/-v`: Display version and quit.
|
- `--version/-v`: Display version and quit.
|
||||||
- `--input-profile/-i`: Specifies input profile name to use (for player #0 only).
|
- `--input-profile/-i`: Specifies input profile name to use (for player #0 only).
|
||||||
|
- `--null-render/-n`: Forces the usage of the "Null" render backend irrespective of settings.
|
||||||
|
- `--filter/-x`: Sets the debug log filter irrespective of settings.
|
||||||
|
- `--singlecore/-s`: Forces single-core regardless of settings.
|
||||||
|
|||||||
+32
-10
@@ -191,7 +191,6 @@ int main(int argc, char** argv) {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int argc_w;
|
int argc_w;
|
||||||
auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w);
|
auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w);
|
||||||
|
|
||||||
if (argv_w == nullptr) {
|
if (argv_w == nullptr) {
|
||||||
LOG_CRITICAL(Frontend, "Failed to get command line arguments");
|
LOG_CRITICAL(Frontend, "Failed to get command line arguments");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -204,10 +203,13 @@ int main(int argc, char** argv) {
|
|||||||
std::optional<u16> override_gdb_port{};
|
std::optional<u16> override_gdb_port{};
|
||||||
bool use_multiplayer = false;
|
bool use_multiplayer = false;
|
||||||
bool fullscreen = false;
|
bool fullscreen = false;
|
||||||
|
bool force_null_render = false;
|
||||||
|
bool force_single_core = false;
|
||||||
std::string nickname{};
|
std::string nickname{};
|
||||||
std::string password{};
|
std::string password{};
|
||||||
std::string address{};
|
std::string address{};
|
||||||
std::string input_profile{};
|
std::string input_profile{};
|
||||||
|
std::optional<std::string> log_filter{};
|
||||||
u16 port = Network::DefaultRoomPort;
|
u16 port = Network::DefaultRoomPort;
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
@@ -222,6 +224,9 @@ int main(int argc, char** argv) {
|
|||||||
{"user", required_argument, 0, 'u'},
|
{"user", required_argument, 0, 'u'},
|
||||||
{"version", no_argument, 0, 'v'},
|
{"version", no_argument, 0, 'v'},
|
||||||
{"input-profile", no_argument, 0, 'i'},
|
{"input-profile", no_argument, 0, 'i'},
|
||||||
|
{"null-render", no_argument, 0, 'n'},
|
||||||
|
{"singlecore", no_argument, 0, 's'},
|
||||||
|
{"filter", no_argument, 0, 'x'},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
// clang-format on
|
// clang-format on
|
||||||
};
|
};
|
||||||
@@ -259,7 +264,7 @@ int main(int argc, char** argv) {
|
|||||||
if (!std::regex_match(str_arg, re)) {
|
if (!std::regex_match(str_arg, re)) {
|
||||||
std::cout << "Wrong format for option --multiplayer\n";
|
std::cout << "Wrong format for option --multiplayer\n";
|
||||||
PrintHelp(argv[0]);
|
PrintHelp(argv[0]);
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
@@ -269,17 +274,16 @@ int main(int argc, char** argv) {
|
|||||||
password = match[2];
|
password = match[2];
|
||||||
address = match[3];
|
address = match[3];
|
||||||
if (!match[4].str().empty()) {
|
if (!match[4].str().empty()) {
|
||||||
port = static_cast<u16>(std::strtoul(match[4].str().c_str(), nullptr, 0));
|
port = u16(std::strtoul(match[4].str().c_str(), nullptr, 0));
|
||||||
}
|
}
|
||||||
std::regex nickname_re("^[a-zA-Z0-9._\\- ]+$");
|
std::regex nickname_re("^[a-zA-Z0-9._\\- ]+$");
|
||||||
if (!std::regex_match(nickname, nickname_re)) {
|
if (!std::regex_match(nickname, nickname_re)) {
|
||||||
std::cout
|
LOG_ERROR(Frontend, "Nickname is not valid. Must be 4 to 20 alphanumeric characters");
|
||||||
<< "Nickname is not valid. Must be 4 to 20 alphanumeric characters.\n";
|
return -1;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
if (address.empty()) {
|
if (address.empty()) {
|
||||||
std::cout << "Address to room must not be empty.\n";
|
LOG_ERROR(Frontend, "Address to room must not be empty");
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -292,7 +296,17 @@ int main(int argc, char** argv) {
|
|||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
PrintVersion();
|
PrintVersion();
|
||||||
return 0;
|
return -1;
|
||||||
|
case 'n':
|
||||||
|
force_null_render = true;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
force_single_core = true;
|
||||||
|
break;
|
||||||
|
case 'x':
|
||||||
|
log_filter = argv[optind];
|
||||||
|
++optind;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -309,7 +323,7 @@ int main(int argc, char** argv) {
|
|||||||
// apply the log_filter setting
|
// apply the log_filter setting
|
||||||
// the logger was initialized before and doesn't pick up the filter on its own
|
// the logger was initialized before and doesn't pick up the filter on its own
|
||||||
Common::Log::Filter filter;
|
Common::Log::Filter filter;
|
||||||
filter.ParseFilterString(Settings::values.log_filter.GetValue());
|
filter.ParseFilterString(log_filter.value_or(Settings::values.log_filter.GetValue()));
|
||||||
Common::Log::SetGlobalFilter(filter);
|
Common::Log::SetGlobalFilter(filter);
|
||||||
|
|
||||||
if (!program_args.empty()) {
|
if (!program_args.empty()) {
|
||||||
@@ -330,6 +344,14 @@ int main(int argc, char** argv) {
|
|||||||
Settings::values.gdbstub_port = *override_gdb_port;
|
Settings::values.gdbstub_port = *override_gdb_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (force_single_core) {
|
||||||
|
Settings::values.use_multi_core = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (force_null_render) {
|
||||||
|
Settings::values.renderer_backend = Settings::RendererBackend::Null;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
LocalFree(argv_w);
|
LocalFree(argv_w);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user