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

allow switch abbrevations as an option #401

Merged
merged 1 commit into from
Aug 8, 2018

Conversation

presto8
Copy link
Contributor

@presto8 presto8 commented Aug 7, 2018

One feature I missed from argparse is the ability to have abbreviations or partial switches (such as "--foo" matching "--foobar", assuming no ambiguous conflicts). This patch attempts to add that. I also added a unit test and it seems to pass. I'm not sure if the authors are in favor of this feature, but sharing it in case it would be beneficial to others.

P.S. I looked around in the code and docs for an already existing implementation, I hope I didn't miss it and do redundant work :-)

@coveralls
Copy link

coveralls commented Aug 7, 2018

Coverage Status

Coverage increased (+0.05%) to 82.254% when pulling ee4eba9 on presto8:master into 2b5a82a on tomerfiliba:master.

@henryiii
Copy link
Collaborator

henryiii commented Aug 7, 2018

Nice, as long as it's optional (it is) I like it. Would you like to add a note to the docs?

@presto8
Copy link
Contributor Author

presto8 commented Aug 7, 2018

Thanks! Sure, let me update the docs, rebase the change and update the pull request.

@henryiii
Copy link
Collaborator

henryiii commented Aug 7, 2018

Ignore the drop in coverage, it is because the Travis 2.6 build originally failed and I had to rerun it.

By the way, when you say for "backward consistency", it's also there to reduce the possibility of a typo. I think this was actually listed as the main reason Plumbum does not simply sit on top of argparse in the current documentation. Argparse even gained the ability to not match partial arguments in Python 3.5 with allow_abbrev.

I wonder if a similar addition could be make to CLI11...

@henryiii
Copy link
Collaborator

henryiii commented Aug 7, 2018

One final note: this could be very useful as a helper for adding tab completion support someday also...

@presto8
Copy link
Contributor Author

presto8 commented Aug 7, 2018

I added some docs, I tried to match the style of the existing docs. And that is a good point about typos!

@henryiii henryiii merged commit b2a5257 into tomerfiliba:master Aug 8, 2018
@henryiii
Copy link
Collaborator

henryiii commented Aug 8, 2018

Looks good to me, thanks!

@presto8
Copy link
Contributor Author

presto8 commented Aug 8, 2018

Thank you, as well, for all of your hard work on this great project!

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 this pull request may close these issues.

3 participants