-
Notifications
You must be signed in to change notification settings - Fork 306
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
Completion on short option names allows for exploration of short and long option names #228
Conversation
- previously it would return only a list of short option names - now it returns both short and long option names; in the case when an option has both a short and long name, it will return only the long name Signed-off-by: Nick Wei <[email protected]>
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.
completeShortNames
is no longer an accurate name, probably needs to becompleteNamesForShortPrefix
(and rename the long one tocompleteNamesForLongPrefix
)- I would like that there is still a single code path for completion matching (now code has been duplicated). E.g. re-using
completeOptionNames
, but passing a flag whether or not to consider short names as well, or maybe just matching on the actual result name + prefix?
completion.go
Outdated
repeats := map[string]bool{} | ||
|
||
for name, opt := range s.lookup.longNames { | ||
if !opt.Hidden { |
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 should still check for match
prefix, just like completeOptionName
does
completion.go
Outdated
} | ||
|
||
for name, opt := range s.lookup.shortNames { | ||
if _, exist := repeats[name]; !exist && !opt.Hidden { |
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.
Same here
- preferred more sensible names for completeShortNames and completeLongNames; changed to completeNamesForShortPrefix and completeNamesForLongPrefix - removed code duplication - match prefix is enforced
@jessevdk Thanks for providing the feedback. I have made the requested changes. Please review the changes. |
Not sure I completely understand the GitHub UI: Changes were requested, have been applied, the wait is now for a re-review by @jessevdk, of niet? |
completion.go
Outdated
for name, opt := range s.lookup.longNames { | ||
if strings.HasPrefix(name, match) && !opt.Hidden { | ||
results = append(results, Completion{ | ||
Item: "--" + name, |
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 should use the correct platform dependent prefix (defaultLongOptDelimiter
)
completion.go
Outdated
for name, opt := range s.lookup.shortNames { | ||
if _, exist := repeats[name]; !exist && strings.HasPrefix(name, match) && !opt.Hidden { | ||
results = append(results, Completion{ | ||
Item: "-" + name, |
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 should use the correct platform dependent short option prefix (defaultShortOptDelimiter
)
Signed-off-by: Stu Pollock <[email protected]>
@jessevdk Tanks for the feedback. We have made the suggested changes. Please review at your earliest convenience. |
This PR addresses feature request #224.
option has both a short and long name, it will return only the long name