Clinterface
A very simple library to create a runtime CLI for your Node.js application.
Usage
To use Clinterface, simply install it using NPM and require the instance.
npm install clinterface --save
var clinterface =
Then, initialize it using the following two arguments:
var cli = <Commands> <>
Commands
The commands parameter has to look like this:
commandName: {} // Command object test: {} // Command object
Each command object has a description, a usage and a method field.
// Command object description: 'Simple description of command' usage: 'commandName <name> <password>' { // Do your call handling here }
Now you can use the commands in your running node.js application.
Other ways
You can also add commands using the .command() function. This can be done at any point during runtime.
cli cli
Standard commands
There are a few Standard commands.
Exit:
Exits the application with code 0.
$ exit
Help:
Lists all the available commands.
$ help⌨️ Available commands: help Shows all available commands. exit Exits the process with code 0. $ help exitexit Exits the process with code 0.
Echo, log, warn, error, success
Helper functions to display text in the console. Each with respective coloring and formatting.
$ echo This is a test!This is a test! $ success This is good![Clinterface 🎉 ] This is good!
Options
You can pass the option parameter. You can modify these parameters:
available: '⌨️ Available commands:' bye: '🖖 Bye bye!' prefix: '🤖 > ' errorPrefix: '[Clinterface ⚡️ ]' successPrefix: '[Clinterface 🎉 ]' warningPrefix: '[Clinterface 🕵 ]' logPrefix: '[Clinterface 📝 ]' hideRegisterLogs: true