l3nz / cli-matic

Compact, hands-free [sub]command line parsing library for Clojure.
Eclipse Public License 2.0
361 stars 29 forks source link

Suggesting sub-commands #26

Closed l3nz closed 5 years ago

l3nz commented 6 years ago

It would be nice to detect mis-spellings and suggest alternatives. Something similar happens in clj-sub-command.

See https://crossclj.info/fun/clj-sub-command.core/candidates.html

For example what git does is:

$ git dd amm/
git: 'dd' is not a git command. See 'git --help'.

The most similar command is
    add
jwhitlark commented 5 years ago

I've got a branch that does:

[jason@penguin toycalc]$ clj -m toycalc add -a 40 -b 2
42
[jason@penguin toycalc]$ clj -m toycalc aad -a 40 -b 2
** ERROR: **
You called aad, did you mean to call add?
[jason@penguin toycalc]$ clj -m toycalc zoo -a 40 -b 2
** ERROR: **
Unknown sub-command
....

I'm going to tidy it up a bit, before I open a PR. In the future it could probably be modified to give the option of running the updated command with the given args....

l3nz commented 5 years ago

Looks yummy! maybe I'quote the subcommand, like:

You called subcommand 'aad', did you mean to call 'add'?

So they stand out a bit more.

l3nz commented 5 years ago

This is what git would do:

$ git commit-m "...."
git: 'commit-m' is not a git command. See 'git --help'.

The most similar command is
    commit-tree
l3nz commented 5 years ago

I saw PR #49 - not sure if I'm merging or doing it manually, but thanks. I think it rocks! 🥇

jwhitlark commented 5 years ago

Yea, I'm starting a new job, so time is short. But I got all the functionality in, IIRC, I just thought it needed a bit of polishing.

On Thu, Nov 15, 2018 at 5:36 AM lenz notifications@github.com wrote:

I saw PR #49 https://github.com/l3nz/cli-matic/pull/49 - not sure if I'm merging or doing it manually, but thanks. I think it rocks! 🥇

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/l3nz/cli-matic/issues/26#issuecomment-439042117, or mute the thread https://github.com/notifications/unsubscribe-auth/AADovBjPeyU7j3t3eLaEH5FKyG0_sKUEks5uvW3egaJpZM4U_45p .

l3nz commented 5 years ago

This is fixed in 0.2.5 - try it! 😃