Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ++ as an alternative separator to -- for user CLI arguments #68532

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion doc/classes/OS.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,12 @@
<method name="get_cmdline_user_args">
<return type="PackedStringArray" />
<description>
Similar to [method get_cmdline_args], but this returns the user arguments (any argument passed after the double dash [code]--[/code] argument). These are left untouched by Godot for the user.
Similar to [method get_cmdline_args], but this returns the user arguments (any argument passed after the double dash [code]--[/code] or double plus [code]++[/code] argument). These are left untouched by Godot for the user. [code]++[/code] can be used in situations where [code]--[/code] is intercepted by another program (such as [code]startx[/code]).
For example, in the command line below, [code]--fullscreen[/code] will not be returned in [method get_cmdline_user_args] and [code]--level 1[/code] will only be returned in [method get_cmdline_user_args]:
[codeblock]
godot --fullscreen -- --level 1
# Or:
godot --fullscreen ++ --level 1
[/codeblock]
</description>
</method>
Expand Down
4 changes: 2 additions & 2 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print("\n");

OS::get_singleton()->print("Run options:\n");
OS::get_singleton()->print(" -- Separator for user-provided arguments. Following arguments are not used by the engine, but can be read from `OS.get_cmdline_user_args()`.\n");
OS::get_singleton()->print(" --, ++ Separator for user-provided arguments. Following arguments are not used by the engine, but can be read from `OS.get_cmdline_user_args()`.\n");
#ifdef TOOLS_ENABLED
OS::get_singleton()->print(" -e, --editor Start the editor instead of running the scene.\n");
OS::get_singleton()->print(" -p, --project-manager Start the project manager, even if a project is auto-detected.\n");
Expand Down Expand Up @@ -1286,7 +1286,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
goto error;
}

} else if (I->get() == "--") {
} else if (I->get() == "--" || I->get() == "++") {
Calinou marked this conversation as resolved.
Show resolved Hide resolved
adding_user_args = true;
} else {
main_args.push_back(I->get());
Expand Down