ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.23k stars 351 forks source link

use spelling distance to suggest packages when one typoes #4029

Open c-cube opened 4 years ago

c-cube commented 4 years ago

instead of:

$ opam info opclib-endian
[ERROR] No package matching opclib-endian found

it'd be neat to suggest ocplib-endian, like ocamlc does :slightly_smiling_face:

rjbou commented 4 years ago

It would a good plus to have. The only thing that make me think about it twice, is if the user do a simple copy-paste without checking, it can result on the install of an unwanted package, that can do to a lot of change on the switch... but maybe I'm overthinking...

dra27 commented 3 years ago

@rjbou - I think @c-cube means:

$ opam info opclib-endian
[ERROR] No package matching opclib-endian found
Hint: Did you mean ocplib-endian?

rather than it actually doing the install (and it doesn't propose the command for the user to copy blindly)

c-cube commented 3 years ago

it's a good question whether this is desirable in opam install indeed. At the very least I think it'd have to ask for confirmation before fixing the typo, in a way that -y doesn't override.

dra27 commented 3 years ago

I think it'd be OK with the hint. I don't think any commands should be interactive about this (i.e. the user should have to issue a new, corrected command), or were you hoping that opam show opclib-endian might do something like:

$ opam info opclib-endian
[WARNING] No package matching opclib-endian found
Hint: Did you mean ocplib-endian?

<><> ocplib-endian: information on all versions <><><><><><><><><><><><><><><><>
name                   ocplib-endian
...

?

c-cube commented 3 years ago

Honestly I think even an error message mentioning the "did you mean" is fine, it helps avoiding scratching one's head because of a hard to spot typo.

kit-ty-kate commented 3 years ago

Honestly I think even an error message mentioning the "did you mean" is fine, it helps avoiding scratching one's head because of a hard to spot typo.

i agree, that would be nice to have