clap icon indicating copy to clipboard operation
clap copied to clipboard

Environment variable name aliases

Open Aeron opened this issue 4 months ago • 1 comments

Please complete the following tasks

Clap Version

4.4.8

Describe your use case

Clap already supports aliases for short and long argument names, which is superb, especially for keeping backward compatibility. Yet environment variables lack this feature that can be useful in all the same cases.

For example, if my CLI changes one of its arguments’ name, I can keep compatibility with short_alias and alias functions and derive parameters. But if such an argument has an environment variable assigned, I either need to keep the name that became inconsistent with the argument name or introduce a breaking CLI change.

For another case, the same will be true if I no longer need separate arguments for something that now can be treated as one value, so I need to merge two argument names. The short_aliases and aliases will cover it great. But environment variables will hold me back from doing so.

Describe the solution you'd like

It’d be nice to have the same alias options for environment variables, like env_aliases and env_alias—a super-similar implementation to what argument names have.

Alternatives, if applicable

No response

Additional Context

I can prepare a PR if there are no objections, considerations, or pitfalls I’m missing. Maybe I overlooked something, or there are some limitations.

Aeron avatar Apr 08 '24 09:04 Aeron