Ninja Parading Musically
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    commandmentpublic

    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.

    Keywords

    none

    install

    npm i commandment

    Downloadsweekly downloads

    4

    version

    0.2.2

    license

    none

    repository

    github.com

    last publish

    collaborators

    • avatar