UNPKG

tooljs-tool

Version:

Composible Tooling for JavaScript

78 lines (66 loc) 1.12 kB
/** * Module dependencies. */ var debug = require('debug'); /** * Add plugins. * * @param {Function} fn * @return {Tool} * @api public */ exports.use = function(fn){ this.middleware.push(fn); return this; }; /** * Add non-prompted attributes. * * @param {String} name * @param {Mixed} opts * @return {Tool} * @api public */ exports.attr = function(name, opts){ opts = opts || {}; opts.name = name; this.attrs[name] = opts; return this; }; /** * Add inputs. * * @param {String} name * @param {Mixed} opts * @return {Tool} * @api public */ exports.input = exports.option = function(name, opts){ opts = opts || {}; opts.name = name; this.inputs[name] = opts; return this; }; /** * Add outputs. * * @param {String} name * @param {Mixed} opts * @return {Tool} * @api public */ exports.output = function(name, opts){ opts = opts || {}; opts.name = name; this.outputs[name] = opts; return this; }; /** * Execute. */ exports.exec = function(opts, fn){ if ('function' == typeof opts) fn = opts, opts = {}; var tool = new this(opts); tool.exec(fn); };