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

Warn on unknown command line arguments #98895

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Nov 6, 2024

This eases troubleshooting when working with command line arguments.

Warnings are only printed if the argument does not exist as a file or directory path (relative or absolute). This allows positional arguments to keep working as they are now, without printing warnings when a project reads positional arguments to perform operations on files (e.g. when drag-and-dropping a file onto a project executable).

This now prints a warning:

godot --non-existent-argument

This still doesn't print a warning, as it's an user argument (projects can check for invalid arguments on their own):

godot -- --non-existent-argument

This doesn't print a warning if the file/folder path exists:

godot /path/to/file.txt

A warning is still printed if the file/folder doesn't exist. Drag-and-drop associations always refer to existing files/folders, so that scenario was unlikely to be encountered.

This eases troubleshooting when working with command line arguments.

Warnings are only printed if the argument does not exist as a file
or directory path (relative or absolute). This allows positional arguments
to keep working as they are now, without printing warnings when a project
reads positional arguments to perform operations on files (e.g. when
drag-and-dropping a file onto a project executable).

This now prints a warning:

    godot --non-existent-argument

This still doesn't print a warning, as it's an user argument:

    godot -- --non-existent-argument

This doesn't print a warning if the file/folder path exists:

    godot /path/to/file.txt

A warning is still printed if the file/folder doesn't exist. Drag-and-drop
associations always refer to existing files/folders, so that scenario was
unlikely to be encountered.
Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

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

This means that arguments passed for get_cmdline_args() will always result in a warning, but I think there is no way around that? 🤔
Other than that looks fine.

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.

Close Godot on invalid command line arguments
2 participants