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

Add support for command-line user arguments. #63624

Merged
merged 1 commit into from
Aug 1, 2022

Conversation

reduz
Copy link
Member

@reduz reduz commented Jul 29, 2022

Implements the standard Unix double dash (--) commandline argument:

  • Arguments after a double dash (--) are ignored by Godot and stored for the user.
  • User can access them via OS.get_cmdline_user_args()

Example:

godot.exe scene_to_run.tscn --fullscreen -- --start-level factory

FAQ:

Q: What's wrong with using the regular Godot commandline for these things?
A: Godot has a very complex and powerful support for lots of things that can be configured via command-line arguments. As arguments can have sub-arguments or arguments used standalone (as example godot.exe --position 20,20 scene.tscn --always-on-top) the parser could ignore the ones it does not recognize, but then it has no idea what to do with the sub-arguments.

Bugsquad edit: This closes godotengine/godot-proposals#2797 and closes #44750.

@reduz reduz requested review from a team as code owners July 29, 2022 13:38
@reduz reduz requested a review from a team as a code owner July 29, 2022 16:00
@zaevi
Copy link
Contributor

zaevi commented Jul 29, 2022

Solves #44750

@Calinou Calinou added this to the 4.0 milestone Jul 29, 2022
doc/classes/OS.xml Outdated Show resolved Hide resolved
doc/classes/OS.xml Outdated Show resolved Hide resolved
main/main.cpp Outdated Show resolved Hide resolved
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good to merge after applying suggestions.

main/main.cpp Outdated Show resolved Hide resolved
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue to fix, otherwise looks fine.

The man page and shell completion files should also be updated but I guess that's something best left to closer to the 4.0 release, there are likely other new/changed options that need to be resynced.

After this I think we should look into removing support for passing unknown arguments before --. This would solve a lot of confusion for users when they don't use the options properly and don't understand why it complains that it can't load a scene. (We could add --scene <path> for loading scenes instead of interpreting any standalone unknown arg as a scene path.)

@akien-mga akien-mga force-pushed the commandline-user-args branch 3 times, most recently from 6ec2bdc to ed383b3 Compare July 31, 2022 22:07
Implements the standard Unix double dash (--) commandline argument:
* Arguments after a double dash (--) are ignored by Godot and stored for the user.
* User can access them via `OS.get_cmdline_user_args()`

Example:

`godot.exe scene_to_run.tscn --fullscreen -- --start-level 2`
@akien-mga akien-mga merged commit 4d4575d into godotengine:master Aug 1, 2022
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Separate command line arguments from engine and game/editor Play Scene passes an extra cmdline arg.
4 participants