CLI with commands, options and arguments
A javascript CLI with commands and options
Install it
npm install wcli --save
Use it
var Cli = ;cli = "serve": log: "l" 'Enable logging' port: 'p' 'Listen on port' 8080 "dump": path: "p" "Store data at path" "/tmp" ; cli { // here your serve code;}cli { // here your dump code} cli;
Use normally from your terminal
$ node myapp.js serve --log -p 8081
The help command
The -h
or --help
option shows the help.
$ node myapp.js --help$ node myapp.js serve -h
Console and colors
You have few helpers to write strings in your console
- info - normal text
- error - underline and red
- fatal - error + exit with code 1
This project includes colors.js in order to write down colored information.
cli;
Init hook
You can execute a script before your command
var Cli = ;cli = "serve": log: "l" 'Enable logging' port: 'p' 'Listen on port' 8080 "dump": path: "p" "Store data at path" "/tmp" ; cli { // do whatever you want and return the cli return this;}; ...