psibi / tldr-hs

Haskell tldr client
BSD 3-Clause "New" or "Revised" License
92 stars 14 forks source link

Add suggestions for wrongly typed commands #41

Open alirezaghey opened 3 years ago

alirezaghey commented 3 years ago

When someone makes a typo in writing out a command, say tldr fiel instead of tldr file, the program suggests the top n nearest matches in its database based on an approximate string matching algorithm. We can further limit the suggestions to have some minimum proximity to the original typed command, so that the suggestions are not very far fetched in case the command is something strange.

Ubuntu has something similar at its command prompt. For instance, when you type fiel, it outputs the following:

Command 'fiel' not found, did you mean:

  command 'field' from deb rheolef (7.1-1)
  command 'file' from deb file (1:5.38-4)
psibi commented 3 years ago

That would be a nice feature! I'm not opposed to a PR implementing it.