[qt, cmd] Document & fix some inconsistencies with command line arguments (#3104)
- documents command line arguments - allows you to specify files starting with `-` Signed-off-by: lizzie lizzie@eden-emu.dev Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3104 Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Reviewed-by: crueter <crueter@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
0eed5100f9
commit
16ca7851c5
|
|
@ -0,0 +1,22 @@
|
|||
# User Handbook - Command Line
|
||||
|
||||
There are two main applications, an SDL2 based app (`eden-cli`) and a Qt based app (`eden`); both accept command line arguments.
|
||||
|
||||
## eden
|
||||
- `./eden <path>`: Running with a single argument and nothing else, will make the emulator look for the given file and load it, this behaviour is similar to `eden-cli`; allows dragging and dropping games into the application.
|
||||
- `-g <path>`: Alternate way to specify what to load, overrides. However let it be noted that arguments that use `-` will be treated as options/ignored, if your game, for some reason, starts with `-`, in order to safely handle it you may need to specify it as an argument.
|
||||
- `-f`: Use fullscreen.
|
||||
- `-u <number>`: Select the index of the user to load as.
|
||||
- `-qlaunch`: Launch QLaunch.
|
||||
- `-setup`: Launch setup applet.
|
||||
|
||||
## eden-cli
|
||||
- `--debug/-d`: Enter debug mode, allow gdb stub at port `1234`
|
||||
- `--config/-c`: Specify alternate configuration file.
|
||||
- `--fullscreen/-f`: Set fullscreen.
|
||||
- `--help/-h`: Display help.
|
||||
- `--game/-g`: Specify the game to run.
|
||||
- `--multiplayer/-m`: Specify multiplayer options.
|
||||
- `--program/-p`: Specify the program arguments to pass (optional).
|
||||
- `--user/-u`: Specify the user index.
|
||||
- `--version/-v`: Display version and quit.
|
||||
|
|
@ -12,4 +12,5 @@ This handbook is primarily aimed at the end-user - baking useful knowledge for e
|
|||
- **[Testing](Testing.md)**
|
||||
- **[Data, savefiles and storage](Storage.md)**
|
||||
- **[Orphaned Profiles](Orphaned.md)**
|
||||
- **[Command Line](CommandLine.md)**
|
||||
- **[Native Application Development](Native.md)**
|
||||
|
|
|
|||
|
|
@ -627,75 +627,43 @@ MainWindow::MainWindow(bool has_broken_vulkan)
|
|||
bool has_gamepath = false;
|
||||
bool is_fullscreen = false;
|
||||
|
||||
for (int i = 1; i < args.size(); ++i) {
|
||||
// Preserves drag/drop functionality
|
||||
if (args.size() == 2 && !args[1].startsWith(QChar::fromLatin1('-'))) {
|
||||
game_path = args[1];
|
||||
has_gamepath = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Launch game in fullscreen mode
|
||||
// Preserves drag/drop functionality
|
||||
if (args.size() == 2 && !args[1].startsWith(QChar::fromLatin1('-'))) {
|
||||
game_path = args[1];
|
||||
has_gamepath = true;
|
||||
} else for (int i = 1; i < args.size(); ++i) {
|
||||
if (args[i] == QStringLiteral("-f")) {
|
||||
// Launch game in fullscreen mode
|
||||
is_fullscreen = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Launch game with a specific user
|
||||
if (args[i] == QStringLiteral("-u")) {
|
||||
if (i >= args.size() - 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (args[i + 1].startsWith(QChar::fromLatin1('-'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (args[i] == QStringLiteral("-u") && i < args.size() - 1) {
|
||||
// Launch game with a specific user
|
||||
int user_arg_idx = ++i;
|
||||
bool argument_ok;
|
||||
std::size_t selected_user = args[user_arg_idx].toUInt(&argument_ok);
|
||||
|
||||
if (!argument_ok) {
|
||||
// try to look it up by username, only finds the first username that matches.
|
||||
const std::string user_arg_str = args[user_arg_idx].toStdString();
|
||||
const auto user_idx = QtCommon::system->GetProfileManager().GetUserIndex(user_arg_str);
|
||||
|
||||
if (user_idx == std::nullopt) {
|
||||
LOG_ERROR(Frontend, "Invalid user argument");
|
||||
std::string const user_arg_str = args[user_arg_idx].toStdString();
|
||||
auto const user_idx = QtCommon::system->GetProfileManager().GetUserIndex(user_arg_str);
|
||||
if (user_idx != std::nullopt) {
|
||||
selected_user = user_idx.value();
|
||||
} else {
|
||||
LOG_ERROR(Frontend, "Invalid user argument '{}'", user_arg_str);
|
||||
continue;
|
||||
}
|
||||
|
||||
selected_user = user_idx.value();
|
||||
}
|
||||
|
||||
if (!QtCommon::system->GetProfileManager().UserExistsIndex(selected_user)) {
|
||||
LOG_ERROR(Frontend, "Selected user doesn't exist");
|
||||
continue;
|
||||
if (QtCommon::system->GetProfileManager().UserExistsIndex(selected_user)) {
|
||||
Settings::values.current_user = s32(selected_user);
|
||||
user_flag_cmd_line = true;
|
||||
} else {
|
||||
LOG_ERROR(Frontend, "Selected user {} doesn't exist", selected_user);
|
||||
}
|
||||
|
||||
Settings::values.current_user = static_cast<s32>(selected_user);
|
||||
|
||||
user_flag_cmd_line = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Launch game at path
|
||||
if (args[i] == QStringLiteral("-g")) {
|
||||
if (i >= args.size() - 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (args[i + 1].startsWith(QChar::fromLatin1('-'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (args[i] == QStringLiteral("-g") && i < args.size() - 1) {
|
||||
// Launch game at path
|
||||
game_path = args[++i];
|
||||
has_gamepath = true;
|
||||
}
|
||||
|
||||
if (args[i] == QStringLiteral("-qlaunch"))
|
||||
} else if (args[i] == QStringLiteral("-qlaunch"))
|
||||
should_launch_qlaunch = true;
|
||||
if (args[i] == QStringLiteral("-setup"))
|
||||
else if (args[i] == QStringLiteral("-setup"))
|
||||
should_launch_setup = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue