@bendn/gdcli
Version:
godot cli utility
51 lines (41 loc) • 1.63 kB
Markdown
[](https://godotengine.org "Made with godot")
<a href='https://ko-fi.com/bendn' title='Buy me a coffee' target='_blank'><img height='28' src='https://storage.ko-fi.com/cdn/brandasset/kofi_button_red.png' alt='Buy me a coffee'> </a>
A utility for parsing command line arguments for godot.
> **Note** Versions < 2.0.0 are for 3.x
> **Warning**
>
> Waiting 4 [godot-proposals/4815](https://github.com/godotengine/godot-proposals/issues/4815) for the full experience.
---
- 0-\* Arguments
- Default values
- Help creation
- Any number of triggers
```gdscript
var p = Parser.new()
p.add_argument(Arg.new({
triggers = ["-F", "--fly"],
n_args = 2,
help = "Fly places",
default = ["sky", "ground"]
}))
p.add_argument(Arg.new({
triggers = ["--eat"],
n_args = "*",
help = "eats all args you give it",
dest = "restaurant"
}))
p.add_argument(Arg.new({
triggers = ["-H", "-?"],
dest = "help",
help = "show this help message and exit",
action = "store_true"
}))
var args = p.parse_arguments(OS.get_cmdline_args() + OS.get_cmdline_user_args())
if args.get("help", false):
print(p.help())
else:
print(args)
```