Console io provider for running Node.JS applications.
This program is a library that provides management of the console user input during the execution of the application. With Command.IO, you can simply intercept the console input commands and bind action on this. For each command you can associate description that is used by Command.IO to generate an inline help.
Command.IO is publish under MIT license.
npm install command.io
Module name :
Command.IO provide by defaut two commands on the application run :
For developers, Command.IO provides the folowing methods :
The addCommand and addCommands methods use the command descriptor. This is an object what describe the command. It take this following parameters :
The action of a command is a function what call when the user type the command. It takes in parameter the list of words that follow the command (one argument by word). The function take an object in context (this) what provide utilities to manage the command execution :
The module is initialized on load by require.
var commandio = require'command.io';
Warning There are a refactoring process on this command. Check this acticle.
addCommand methode take three parameters : the name of command, the description for help
generation and the action callback. This command return the Command.IO API and its call can be chained.
var commandio = require'command.io';commandioaddCommandname: 'command1'description: 'The first command'console.log'Action of first command';;// Exemple of chained call.commandioaddCommandname: 'command2'description: 'The second command'console.log'Action of second command';addCommandname: 'command3'description: 'The third command'console.log'Action of third command';;
addCommands take an array of objects what describe each commands.
var commandio = require'command.io';commandioaddCommandsname: 'command4'description: 'The fourth command'console.log'Action of fourth command';name: 'command5'description: 'The fifth command'console.log'Action of fifth command';;
beforeExit take only a callback in parameter. The action what store in a collection and execute on exit command call, juste before the application closing.
var commandio = require'command.io';commandiobeforeExitconsole.log'I just have time to say goodbye.';;
###0.2.0 - 28/08/13: 0.2.0-a2 - 27/08/13:
0.2.0-a - 24/07/13: