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

Completion on short option names allows for exploration of short and long option names #228

Merged
merged 3 commits into from
Jul 20, 2017

Conversation

n4wei
Copy link

@n4wei n4wei commented May 5, 2017

This PR addresses feature request #224.

  • 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

- 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]>
@n4wei n4wei changed the title changed the behavior of completing short option names Completion on short option names allows for exploration of short and long option names May 5, 2017
Copy link
Owner

@jessevdk jessevdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. completeShortNames is no longer an accurate name, probably needs to be completeNamesForShortPrefix (and rename the long one to completeNamesForLongPrefix)
  2. 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 {
Copy link
Owner

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 {
Copy link
Owner

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
@n4wei
Copy link
Author

n4wei commented May 31, 2017

@jessevdk Thanks for providing the feedback. I have made the requested changes. Please review the changes.

@dkoper
Copy link

dkoper commented Jun 21, 2017

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,
Copy link
Owner

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,
Copy link
Owner

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)

@n4wei
Copy link
Author

n4wei commented Jul 18, 2017

@jessevdk Tanks for the feedback. We have made the suggested changes. Please review at your earliest convenience.

@jessevdk jessevdk merged commit 96dc062 into jessevdk:master Jul 20, 2017
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.

4 participants