-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add possiblity to address the same option via several alias names #44
Comments
Hi! Thank you for this project @SupImDos. I'd like to +1 this request for aliases so that we could have short arguments as well. Was curious if this enhancement is still planned? Thanks! |
@donaldcampbelljr Certainly still on my radar, but couldn't say when I'll have time to do this. If you (or someone else reading this) were interested in a PR, the following pointers could help:
Some things to think about re: API / behaviour expectations
Probably some other things I am forgetting here, but it should be relatively straight forward as long as its clear what the expectations are for the edge cases. If you wanted a hack / escape hatch for now, you could try something like the following: # Create parser with model
parser = pydantic_argparse.ArgumentParser(model=...)
# Add `-s` short argument for existing `--string` argument
argument = parser._option_string_actions["--string"]
argument.option_strings = ("-s", "--string")
parser._option_string_actions["-s"] = argument I haven't tested this, but to the point the |
Partially completed in #73. Going to follow it up with another PR with some tests / docs if required. |
This should now be possible in |
It would be nice to have the possibility to define in the
pydantic.BaseModel
Field definition the possible names for the cli arguments. It would be possible to have both: the short and long versions of the same argument.example:
above would give the possibility to specify the argument in the command line as
command --my-custom-debug
How to add the short version of the same argument i.e:
-d
If support for
aliases=('d', 'my-custom-debug')
would be added it would be nice aspydantic.Field
does support extra argumentsAbove would be interpreted to add the additional names to the parsed arguments
The text was updated successfully, but these errors were encountered: