diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-05-05 19:09:28 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-05-05 19:20:03 +0200 |
commit | cd4b60d0d4e3b8acce5aaa4656fd342c677db4e2 (patch) | |
tree | 662a9d7bb541a07059fee5377ab07576724af166 /doc/classes | |
parent | f74e61fa54520dc092cb12bc35bccccfbeab74cf (diff) |
Handle CLI arguments without a value in `OS.get_cmdline_args()` example
Command lines such as `--host --address 127.0.0.1` are now parsed as
`{"host": "", "address": "127.0.0.1"}`.
Diffstat (limited to 'doc/classes')
-rw-r--r-- | doc/classes/OS.xml | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index 266a2573de..3148478f14 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -175,6 +175,10 @@ if argument.find("=") > -1: var key_value = argument.split("=") arguments[key_value[0].lstrip("--")] = key_value[1] + else: + # Options without an argument will be present in the dictionary, + # with the value set to an empty string. + arguments[argument.lstrip("--")] = "" [/gdscript] [csharp] var arguments = new Godot.Collections.Dictionary(); @@ -185,6 +189,12 @@ string[] keyValue = argument.Split("="); arguments[keyValue[0].LStrip("--")] = keyValue[1]; } + else + { + // Options without an argument will be present in the dictionary, + // with the value set to an empty string. + arguments[keyValue[0].LStrip("--")] = ""; + } } [/csharp] [/codeblocks] |