Skip to content
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

Alias short arguments #1896

Closed
2 tasks done
connorskees opened this issue May 2, 2020 · 3 comments · Fixed by #1901
Closed
2 tasks done

Alias short arguments #1896

connorskees opened this issue May 2, 2020 · 3 comments · Fixed by #1901
Milestone

Comments

@connorskees
Copy link
Contributor

Make sure you completed the following tasks

Describe your use case

I have a project that needs to offer 2 shorthand flags (-s and -t) for the same argument in order to conform to a reference implementation from another language. The latter of the two is hidden and exists only for backwards compatibility; however, some old tools only use the hidden form of the flag.

Describe the solution you'd like

I'd be looking for something similar to Arg::alias but for shorthand arguments. It would probably make sense to have the signature look like

pub fn alias_short<S: Into<&'help str>>(mut self, name: S) -> Self;

that adds a hidden shorthand alias.

The relevant code

pub fn alias<S: Into<&'help str>>(mut self, name: S) -> Self {

Alternatives, if applicable

It shouldn't be too hard to just add a hidden flag and then check if either are set, but it seems unintuitive to only allow aliasing of long arguments.

@kbknapp
Copy link
Member

kbknapp commented May 2, 2020

I agree it's a gap in what we currently offer. I can't say it'll make the cut for the 3.0 release, but it should be added shortly after.

Thanks for issue.

@pksunkara
Copy link
Member

Does that mean we need to rename alias to long_alias and other methods similarly?

@kbknapp
Copy link
Member

kbknapp commented May 4, 2020

Does that mean we need to rename alias to long_alias and other methods similarly?

I hadn't thought that far yet.... ugh. 😟

... [ thinking intensifies ] ...

I'd say no. So long as the docs are explicit that alias is for longs, and if they wish to find something similar but for shorts, look for short_alias I think it's fine.

@bors bors bot closed this as completed in #1901 May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants