mirror of
https://github.com/godotengine/godot.git
synced 2026-02-13 19:05:21 +00:00
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"}`.
This commit is contained in:
parent
f74e61fa54
commit
cd4b60d0d4
1 changed files with 10 additions and 0 deletions
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue