-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
all: Accept shortcuts for stringly-enum options #6174
all: Accept shortcuts for stringly-enum options #6174
Conversation
(Whoops, sorry for the review request, that was too early.) |
e28d7be
to
2cc5ec6
Compare
Changes since last push:
|
GNU testsuite comparison:
|
2cc5ec6
to
91679fc
Compare
Changes since last push:
Is there anything else needed? |
GNU testsuite comparison:
|
LGTM but I would like @tertsdiepraam to comment as he often has great opinions on such subjects |
@@ -66,7 +66,7 @@ impl TypedValueParser for ShortcutValueParser { | |||
let matched_values: Vec<_> = self | |||
.0 | |||
.iter() | |||
.filter(|x| x.get_name().starts_with(value)) | |||
.filter(|x| x.get_name_and_aliases().any(|name| name.starts_with(value))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is clever and I love it :)
Excellent! Let's get this merged indeed! |
We already infer long arguments, like
wc --tot
being equivalent towc --total
. This PR introduces the same functionality for values, just like the GNU tools. In particular, this means the following calls are equivalent:This example also demonstrates that alias resolution does not interfere with value inference: "a" is lexically ambiguous (it might mean "atime" or "access"), but has only one meaning (because "atime" and "access" are the same thing).
The implementation to do that was already there, but was only used in
date(1)
for some reason.This PR is completely different from the following PRs: