node package manager


Command line with evented composition


Stability: 1 - Experimental

Evented command-line.

// your module main.js 
"use strict";
var clie = require('clie'),
    path = require('path');
var commandsDirectory = path.normalize(path.join(__dirname, 'commands'));
module.exports = clie({commandsDirectory: commandsDirectory});
// module that uses your module 
var myModule = require('my-module');
myModule.commands // has all the commands 

Call cli() on required module.

// your module cli.js 
#!/usr/bin/env node
"use strict";
var commandEmitter = require('../index.js').cli();
commandEmitter.on('data', function (data) {
commandEmitter.on('error', function (error) {
// commands/one.js 
"use strict";
var clie = require('clie');
var one = module.exports = clie.command(function (args) {
    var self = this;'one').end();
one.usage = [
  "\nUsage: my-module one",
  "Displays 'one'"

To require the module the command belongs to, it must be called within the command body as depicted below (var myModule = require('../index.js')).

"use strict";
var clie = require('clie');
var two = module.exports = clie.command(function (args) {
    var self = this;
    var myModule = require('../index.js');
    if (args.params.usage) return;
    if ( {
        var oneEmitter =;
        oneEmitter.on('error', self.error);
        oneEmitter.on('end', self.end);
    } else {'two').end();
two.usage = [
  "\nUsage: my-module two [options]",
  "           options: --one (Display 'one' instead of 'two')"

We follow semantic versioning policy ( with a caveat:

Given a version number MAJOR.MINOR.PATCH, increment the:

MAJOR version when you make incompatible API changes,
MINOR version when you add functionality in a backwards-compatible manner, and
PATCH version when you make backwards-compatible bug fixes.

caveat: Major version zero is a special case indicating development version that may make incompatible API changes without incrementing MAJOR version.