saguijs / sagui

:monkey: Front-end tooling in a single dependency
http://sagui.js.org/
MIT License
669 stars 32 forks source link

[RFC] Add handler for unknown commands #362

Closed abdulhannanali closed 7 years ago

abdulhannanali commented 7 years ago

Summary

Right now, as @pirelenito mentioned in #360 we need a handler for unknown actions, which cause the sagui to exit with non zero code, alerting the developers about the problems if any in their setup or sagui. This adds a very minimalistic solution in sagui.

However, I do have a few suggestions, we can use to improve this even further. I hope @pirelenito can look into it too after vacation.

If the current solution is good enough, it's okay too. :+1: I am using exit code 1 in this case.

xaviervia commented 7 years ago

Thanks a lot! This is a great first step. I think redirecting to --help is a good idea; of course adding suggestions would be really nice, but I don’t know what the complexity if that would be. Maybe there is a simple library to handle that.

Kadrei commented 7 years ago

one could easily calculate the levenstheindistance and suggest the one command with the least.

xaviervia commented 7 years ago

Cool, I did find a couple of Levenshtein distance calculator functions:

I assume one can run whatever command the user sent and compute the distance to all the possible commands, and if one goes below a threshold (say, 3) output that one as a suggestion; otherwise, show the --help

Makes sense?

pirelenito commented 7 years ago

I think that the PR is great as it is, given this fixes the more urgent problem.

Regarding @xaviervia's suggestion, could we have it as a separated PR?

Wdyt?

Thanks again @abdulhannanali.

xaviervia commented 7 years ago

I agree with you @pirelenito , I think this is good as it is. Refinements can come as separate releases. Go for it if you want.

pirelenito commented 7 years ago

@abdulhannanali please update your branch from v9, I did a fix that should make your build green (#363)

abdulhannanali commented 7 years ago

@pirelenito Sounds good, I will do it as a separate PR. Thanks a lot @Kadrei for suggestions. I am going to use leven in order to calculate the distance.

Thanks @xaviervia for a great outlook on this problem. I will update with progress on a separate PR

abdulhannanali commented 7 years ago

@pirelenito Did that, hope the build passes.