https://github.com/bend-n/gdcli
https://github.com/bend-n/gdcli
Last synced: 15 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/bend-n/gdcli
- Owner: bend-n
- License: mit
- Created: 2022-07-08T23:08:35.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-18T00:55:35.000Z (almost 2 years ago)
- Last Synced: 2025-03-14T07:47:40.054Z (about 1 month ago)
- Language: GDScript
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# godot cli options parser
[](https://godotengine.org "Made with godot")
[](https://www.npmjs.com/package/@bendn/gdcli)![]()
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.---
## Features
- 0-\* Arguments
- Default values
- Help creation
- Any number of triggers### Usage example
```gdscript
var p = Parser.new() # create the parser
p.add_argument(Arg.new({ # add an argument
triggers = ["-F", "--fly"], # triggers
n_args = 2, # number of arguments
help = "Fly places", # help message
default = ["sky", "ground"] # default args if called without arguments
}))
p.add_argument(Arg.new({ # arg n2
triggers = ["--eat"],
n_args = "*", # any number of arguments
help = "eats all args you give it",
dest = "restaurant" # the variable it goes into (defaults to longest trigger)
}))
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()) # Parse
if args.get("help", false): # Check if we want help
print(p.help()) # Show help
else:
print(args) # Just show args otherwise
```