commandment

0.2.2 • Public • Published

Commandment

Commandline for node.js

Installation

npm install commandment

Usage

main.js
var Commandment = require('commandment')
  , commands = new Commandment({name: 'my-app', command_dir: __dirname + '/commands'});

commands.before_execute(function(context, next) {
  context.hello_helper = function() {
    // You can call me from commands now
    return 'hello world';
  };
});

commands.after_execute(function(context, err, next) {
  if (err) return console.error(err.stack);
  context.log('Yay! Everything is fine');
  next();
});

commands.execute(process.argv);

Commands are just exported from files in the commands directory

commands/hello.js
exports.hello = function(callback) {
  this.log(this.hello_helper());
  callback()
};

// There can be multiple per file
exports.hello_person = function(name, callback) {
  this.log('Hello ' + name);
  callback();
};

License

Copyright (c) 2013 Matt Insler
Licensed under the MIT license.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.2.20latest

Version History

VersionDownloads (Last 7 Days)Published
0.2.20
0.2.10
0.2.00
0.0.10

Package Sidebar

Install

npm i commandment

Weekly Downloads

0

Version

0.2.2

License

none

Last publish

Collaborators

  • mattinsler