Skip to content

feat(cli): prompt for misspelled parameter names #10350

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

Merged
merged 6 commits into from
Nov 6, 2023

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Oct 19, 2023

Part of #10292

Performs a fuzzy-matching based on Levenshtein edit distance when an unknown parameter name is encountered.
Edit distance defaults to len(parameter)/2.
Should result in less guessing about what that parameter was named exactly.

image

@johnstcn johnstcn self-assigned this Oct 19, 2023
@johnstcn johnstcn force-pushed the cj/parameter-did-you-mean branch 2 times, most recently from a162f63 to 6ab0407 Compare October 27, 2023 04:17
@johnstcn johnstcn requested a review from mafredri October 27, 2023 12:10
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

Awesome! 🤩

return int(d[i+1][j+1]), ErrMaxDist
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Not against us having our own implementation, but there's also: https://github.com/agnivade/levenshtein (in this case, the performance optimizations are negligible, though.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I was also considering https://pkg.go.dev/github.com/junegunn/fzf@v0.0.0-20231029150554-1cfa3ee4c7c1/src/algo but didn't want to necessarily add a dep just for this.

Needle: "foo",
MaxDistance: 2,
Haystack: []string{"bar", "boo", "boof"},
Expected: []string{"boo", "boof"},
Copy link
Member

Choose a reason for hiding this comment

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

Should we test some slightly longer inputs as well?

@johnstcn johnstcn force-pushed the cj/parameter-did-you-mean branch from 6ab0407 to 24a04fa Compare November 6, 2023 09:17
@johnstcn johnstcn merged commit 4277ca0 into main Nov 6, 2023
@johnstcn johnstcn deleted the cj/parameter-did-you-mean branch November 6, 2023 13:44
@github-actions github-actions bot locked and limited conversation to collaborators Nov 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants