
nutty
A small and minimal CLI framework
Install
Install the package using NPM:
npm install nutty
Example
//Import nuttyvar nutty = ; //Set the CLI namenutty; //Set the CLI descriptionnutty; //Set the CLI versionnutty; //Use a middlewarenutty; //Run the CLInutty;
Simple usage:
$ hello John
>>>>>>> Hello John!
Use it with options:
$ hello Susan --idiom spanish
>>>>>>> Hola Susan!
API
nutty.set(key, value)
Assigns the value of the setting variable called key
to value
.
nutty; //Initialize the 'name' variable to 'my-app'nutty; //--> Return: ' my-app'
key | description | type | default |
---|---|---|---|
name | The CLI name | string |
'' |
description | The CLI description | string |
'' |
version | The CLI version | string |
'' |
nutty.get(key)
Returns the value of the setting variable called key
.
nutty.use(fn)
Add a new middleware to the CLI. Nutty is based on middlewares, that are functions that have access to the arguments
object and the next
function.
Example:
nutty;
args
Args
is an object with all the arguments of the CLI. It has the following keys:
args.options
: an object with all the options with the formatkey = value
.args.arguments
: a list with all the arguments that didn't have an option associated with them.
Example:
myapp argument1 argument2 --option1 argument3 --option2 --option3 3.123
Then the args object will has the following structure:
next
The next
argument is a function that will call the next middleware on the list when is invoked.
nutty.run()
Run the CLI.
Related
- nutty-log Logger for cli apps and nutty middlewares.
- nutty-command A command middleware for nutty.
License
MIT LICENSE.