-
Notifications
You must be signed in to change notification settings - Fork 28
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
Command Suggestion for Incorrect Subcommands #12
Command Suggestion for Incorrect Subcommands #12
Conversation
f73b400
to
60f4f39
Compare
60f4f39
to
011a301
Compare
32ca892
to
39935c2
Compare
@alicerum can you please review? |
@vinamra28 after discussion with colleagues, I want to ask you to use levenshtein distance function provided by some package. Another option would be put this function into some package like Reasoning is that we don't really want to introduce exact same mathematical problems solving algorithms into multiple project. In case there's a problem with it later, we will have to find and fix all the occurrences of such algorithm, and it's just overall not the best approach. |
39935c2
to
ca2efe9
Compare
@adambkaplan @alicerum updated the PR based on the comments. Used the library https://github.com/texttheater/golang-levenshtein. Can you please review? 🙂 |
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.
Thanks! It looks good. 👍🏼
|
||
// suggestsByPrefixOrLd suggests a command by levenshtein distance or by prefix. | ||
// It returns an empty string if nothing was found | ||
func suggestsByPrefixOrLd(typedName, candidate string, minDistance int) string { |
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.
Nice! 👍🏼
/assign @alicerum |
/approve Looks good to me, thank you very much @vinamra28 |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alicerum The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
ca2efe9
to
22b4898
Compare
Earlier there were no suggestions for shp subcommands but with this patch entering wrong subcommands will give suggestions. example:- shp build cr Error: unknown command "cr" for "shp build" Did you mean this? create Signed-off-by: vinamra28 <vinjain@redhat.com>
Signed-off-by: vinamra28 <vinjain@redhat.com>
22b4898
to
329128e
Compare
/lgtm |
Earlier there were no suggestions for shp subcommands but with this patch entering wrong subcommands will give suggestions.
example:-
Also updated the
.gitignore
file to ignore the binary generated after runninggo build ./cmd/shp
and also ignoring.vscode
dirSigned-off-by: vinamra28 vinjain@redhat.com