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:
Hugo Locurcio 2022-05-05 19:11:30 +02:00
parent 7774cbd8f2
commit 99d9228a2e
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C
1 changed files with 4 additions and 0 deletions

View File

@ -161,6 +161,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("--")] = ""
[/codeblock]
</description>
</method>