[eden-cli] add extra CLI options -n/-x/-s options

Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie
2026-07-03 18:10:43 +00:00
committed by crueter
parent cd003e5ec9
commit 0de3a4a654
2 changed files with 35 additions and 10 deletions
+3
View File
@@ -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.
- `--version/-v`: Display version and quit.
- `--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
View File
@@ -191,7 +191,6 @@ int main(int argc, char** argv) {
#ifdef _WIN32
int argc_w;
auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w);
if (argv_w == nullptr) {
LOG_CRITICAL(Frontend, "Failed to get command line arguments");
return -1;
@@ -204,10 +203,13 @@ int main(int argc, char** argv) {
std::optional<u16> override_gdb_port{};
bool use_multiplayer = false;
bool fullscreen = false;
bool force_null_render = false;
bool force_single_core = false;
std::string nickname{};
std::string password{};
std::string address{};
std::string input_profile{};
std::optional<std::string> log_filter{};
u16 port = Network::DefaultRoomPort;
static struct option long_options[] = {
@@ -222,6 +224,9 @@ int main(int argc, char** argv) {
{"user", required_argument, 0, 'u'},
{"version", no_argument, 0, 'v'},
{"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},
// clang-format on
};
@@ -259,7 +264,7 @@ int main(int argc, char** argv) {
if (!std::regex_match(str_arg, re)) {
std::cout << "Wrong format for option --multiplayer\n";
PrintHelp(argv[0]);
return 0;
return -1;
}
std::smatch match;
@@ -269,17 +274,16 @@ int main(int argc, char** argv) {
password = match[2];
address = match[3];
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._\\- ]+$");
if (!std::regex_match(nickname, nickname_re)) {
std::cout
<< "Nickname is not valid. Must be 4 to 20 alphanumeric characters.\n";
return 0;
LOG_ERROR(Frontend, "Nickname is not valid. Must be 4 to 20 alphanumeric characters");
return -1;
}
if (address.empty()) {
std::cout << "Address to room must not be empty.\n";
return 0;
LOG_ERROR(Frontend, "Address to room must not be empty");
return -1;
}
break;
}
@@ -292,7 +296,17 @@ int main(int argc, char** argv) {
break;
case 'v':
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 {
#ifdef _WIN32
@@ -309,7 +323,7 @@ int main(int argc, char** argv) {
// apply the log_filter setting
// the logger was initialized before and doesn't pick up the filter on its own
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);
if (!program_args.empty()) {
@@ -330,6 +344,14 @@ int main(int argc, char** argv) {
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
LocalFree(argv_w);
#endif