Click or drag to resize

OSGetCmdlineArgs Method

Returns the command-line arguments passed to the engine.

Command-line arguments can be written in any form, including both --key value and --key=value forms so they can be properly parsed, as long as custom command-line arguments do not conflict with engine arguments.

You can also incorporate environment variables using the GetEnvironment(String) method.

You can set editor/main_run_args in the Project Settings to define command-line arguments to be passed by the editor when running the project.

Here's a minimal example on how to parse command-line arguments into a dictionary using the --key=value form for arguments:

var arguments = {}
for argument in OS.get_cmdline_args():
    if argument.find("=") > -1:
        var key_value = argument.split("=")
        arguments[key_value[0].lstrip("--")] = key_value[1]

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
public static string[] GetCmdlineArgs()

Return Value

Type: String

[Missing <returns> documentation for "M:Godot.OS.GetCmdlineArgs"]

See Also