summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrii Doroshenko (Xrayez) <xrayez@gmail.com>2020-07-20 00:19:05 +0300
committerAndrii Doroshenko (Xrayez) <xrayez@gmail.com>2020-07-20 12:09:46 +0300
commitdf80e259cdab0ae7d89ae0b1099819ae5363b7b1 (patch)
tree87b24accaf06527e6d2dbc4a3a855cc024616be0
parent9e34ba48556b71f1f672b5be47d12b0e3f679b86 (diff)
Document the process of parsing command-line arguments
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
-rw-r--r--doc/classes/OS.xml13
1 files changed, 12 insertions, 1 deletions
diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml
index 105def21ca..238bc970ef 100644
--- a/doc/classes/OS.xml
+++ b/doc/classes/OS.xml
@@ -112,7 +112,18 @@
<return type="PackedStringArray">
</return>
<description>
- Returns the command line arguments passed to the engine.
+ Returns the command-line arguments passed to the engine.
+ 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.
+ You can also incorporate environment variables using the [method get_environment] method.
+ You can set [code]editor/main_run_args[/code] 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 [code]--key=value[/code] form for arguments:
+ [codeblock]
+ 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]
+ [/codeblock]
</description>
</method>
<method name="get_connected_midi_inputs">