-
Notifications
You must be signed in to change notification settings - Fork 123
Optparse option aliases #705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I've been wanting this feature for a bit. This will be great to have.
|
Oh dear silly me. Probably should've thought about that first. Here's a fixed version for 4.3. |
Sorry for the delay. I checked this out a bit then got distracted with Godotcon. This works, but I think I would like the following changes:
This allows us to keep all the option names together which is easier to read. In my experience it is rare that you would want more than one alias for an option (I can't think of an example off the top of my head). By putting the optional array at the front, we can still support more aliases but don't have to use a single element array in usual use case. This would change the usage to something like: op.add("--name", "default", "description")
op.add(["--name", "-n"], "default", "description")
op.add(["--name", "--nombre", "--namna", "-n"], "default", "description") |
…rse to Options and updated tests accordingly
83f9f66
to
50a154c
Compare
Okay, it's been updated to have the specified behavior. I also added type hints and docstrings to all the user facing methods and rebuilt the class reference docs for them. |
This looks good. Thanks a lot for adding this. |
#667 describes a regression where
addons/gut/gut_cmdln.gd
stopped recognizing the--script
argument. This PR fixes this problem and also introduces argument aliases to the optparse system.Any option can now be added with any number of aliases. Aliases will be checked to make sure they do not collide with other option names or aliases in the same way that option names are usually checked for collisions. An option's aliases will be printed out at the end of its help string.