Skip to content

Commit 9023f65

Browse files
committed
Merge pull request godotengine#112466 from Cykyrios/fix-cmdline-args-doc
Fix OS.get_cmdline_args documentation
2 parents 3d6ad3f + f7455c1 commit 9023f65

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

doc/classes/OS.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,12 @@
187187
<method name="get_cmdline_args">
188188
<return type="PackedStringArray" />
189189
<description>
190-
Returns the command-line arguments passed to the engine.
190+
Returns the command-line arguments passed to the engine, excluding arguments processed by the engine, such as [code]--headless[/code] and [code]--fullscreen[/code].
191+
[codeblock]
192+
# Godot has been executed with the following command:
193+
# godot --headless --verbose --scene my_scene.tscn --custom
194+
OS.get_cmdline_args() # Returns ["--scene", "my_scene.tscn", "--custom"]
195+
[/codeblock]
191196
Command-line arguments can be written in any form, including both [code]--key value[/code] and [code]--key=value[/code] forms so they can be properly parsed, as long as custom command-line arguments do not conflict with engine arguments.
192197
You can also incorporate environment variables using the [method get_environment] method.
193198
You can set [member ProjectSettings.editor/run/main_run_args] to define command-line arguments to be passed by the editor when running the project.
@@ -231,12 +236,12 @@
231236
Returns the command-line user arguments passed to the engine. User arguments are ignored by the engine and reserved for the user. They are passed after the double dash [code]--[/code] argument. [code]++[/code] may be used when [code]--[/code] is intercepted by another program (such as [code]startx[/code]).
232237
[codeblock]
233238
# Godot has been executed with the following command:
234-
# godot --fullscreen -- --level=2 --hardcore
239+
# godot --fullscreen --custom -- --level=2 --hardcore
235240

236-
OS.get_cmdline_args() # Returns ["--fullscreen", "--level=2", "--hardcore"]
241+
OS.get_cmdline_args() # Returns ["--custom"]
237242
OS.get_cmdline_user_args() # Returns ["--level=2", "--hardcore"]
238243
[/codeblock]
239-
To get all passed arguments, use [method get_cmdline_args].
244+
To get arguments passed before [code]--[/code] or [code]++[/code], use [method get_cmdline_args].
240245
</description>
241246
</method>
242247
<method name="get_config_dir" qualifiers="const">

0 commit comments

Comments
 (0)