defopt icon indicating copy to clipboard operation
defopt copied to clipboard

Argument name suffixes as workaround for name collisions

Open bede opened this issue 3 years ago • 4 comments

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

bede avatar May 11 '22 08:05 bede

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).

anntzer avatar May 11 '22 16:05 anntzer

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

bede avatar May 11 '22 19:05 bede

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.

anntzer avatar May 12 '22 09:05 anntzer

Wonderful, will be in touch

bede avatar May 12 '22 11:05 bede