Clifier
Create cli utility for node.js easily, including:
- Full command/argument parser
- Consistant inputs and arguments
- Auto help generator
- Progress and table generators
Getting Started
Install the module with: npm install clifier
var cli = ; cli name'testcommand' version'0.0.1' description'Hello command !'; cli input'name' '[a-z]+' action { cli; cli; cli; cli; cli; var progress = cli i = 0 { i++; progress; if i == 100 progress; cli; else ; } ; }; cli;
API
require('clifier')
return a Cli
instance.
Cli API
.version(string) : Cli
Set the version of your cli utility
.name(string) : Cli
Set the name of your cli utility
.description(string) : Cli
Set the description of your cli utility
.write(string)
Write something on the stdout
.style(content, style)
Transform content with asked style. Need to be send to write
.
.success(string)
Write a success text on the stdout
.warning(string)
Write a warning text on the stdout
.error(string)
Write an error text on the stderr
.log(string)
Write a log text on the stdout if verbose enabled
.command(name, description) : Command
Create a new command with name and description.
Command API
.input(name, validator) : Command
Add an input to the command.
- name (string) : name of the input
- validator (string) : RegExp to validate the input
.argument(name, description, defaultValue, filter) : Command
Add an argument to the command.
- name (string) : name of the argument (--arg, -arg)
- description (string) : description of the argument
- defaultValue (mixed) : default value of the argument if empty
- filter (function) : filter function for the argument
.action(function(...inputs, ...arguments)) : Command
Action of the command when executed. Function will receive all inputs and arguments in define orders as parameters.
License
See LICENSE
file