CLI Suggestion
It's just a simple module to return a command suggestion based on a try.
Installation
Add to your project:
npm install cli-suggestion --save
Starting
Require and start with options:
var cliSuggestion = ; ... var doSuggestion = ; ;// Did you want to say that?// cmd --version
Then you can receive suggestions passing a string as the attempt:
var return = ; // Just the string, do not pass your app/command.
Options
default: a empty string
command | String | Your command. To be added before suggestion:
Did you want to say that?
command suggestion
default: suggestions.json
file | String | The suggestions JSON file.
If it's invalid we will consider no suggestions.
default: Did you want to say that?
text | String | A humman readable text before suggestion.
Just like GIT.
Suggestion File
It's a JSON file with a array of suggestions.
Each suggestion should have command
(string) and errors
(array of strings) properties.
Examples
You can use 'chalk' to improve your logs.
var cliSuggestion = ;var chalk = ; var suggestion = ; console;// Did you want to say that?// cmd example
Our purpose is to create suggestions to a cli tool, but you can use for anything:
var cliSuggestion = ; var suggestion = ; var suggestionToUseInYourCode = ;// Will return just the suggestion (no text, no command and trimmed)
License
MIT