anntzer / defopt

Effortless argument parser
https://pypi.org/project/defopt/
MIT License
214 stars 11 forks source link

Argument name suffixes as workaround for name collisions #114

Open bede opened 2 years ago

bede commented 2 years ago

Hi, I really like defopt! It's my new go-to CLI library 🙏

One feature I miss from Argh (I think?) is the ability to modify argument names such that the name can be used in the function body without causing collisions.

Say if I want one of my CLI args to be called environment, but don't want it to collide with an existing variable called environment, it would be cool if the CLI arg could be given a different name like environment_ but still appear as --environment in the CLI. Defopt doesn't do this but IIRC Argh does.

If I implemented this, would you consider a PR? Understand if not.

Thanks, Bede

anntzer commented 2 years ago

I guess that for symmetry with the currently existing short kwarg, I could support a long kwarg which could be a {parameter_name: cli_name, ...} mapping (but unlike short, the cli_name would completely replace the parameter_name in the CLI interface).

bede commented 2 years ago

That would be cool! Happy to have a go with some guidance, or whatever you suggest

anntzer commented 2 years ago

Probably best would be for you to write a PR first with the functionality (I don't plan to write the first draft for you, at least :-)), we can then do some review cycles over that.

bede commented 2 years ago

Wonderful, will be in touch