Skip to content
Myr

docs

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 46be01f · Browse files · 2 files+52 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+52 added−3 removed

  • other:+52 added−3 removed

2 files+52 added−3 removed

modified:examples/deploy+1 added-1 removed
11 unmodified lines
12 .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')13 .option('-T, --no-tests', 'ignore test hook')1415program16 .command('setup [env]')16 .command('setup')17 .description('run remote setup commands')18 .action(function(){19 console.log('setup');20 });
18 unmodified lines
modified:lib/commander.js+51 added-2 removed
94 unmodified lines
95 */9697Command.prototype.__proto__ = EventEmitter.prototype;9899/**100 * Add command `name`.101 *102 * Examples:103 *104 * program105 * .version('0.0.1')106 * .option('-C, --chdir <path>', 'change the working directory')107 * .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')108 * .option('-T, --no-tests', 'ignore test hook')109 * 110 * program111 * .command('setup')112 * .description('run remote setup commands')113 * .action(function(){114 * console.log('setup');115 * });116 * 117 * program118 * .command('exec <cmd>')119 * .description('run the given remote command')120 * .action(function(cmd){121 * console.log('exec "%s"', cmd);122 * });123 * 124 * program125 * .command('*')126 * .description('deploy the given env')127 * .action(function(env){128 * console.log('deploying "%s"', env);129 * });130 * 131 * program.parse(process.argv);132 *133 * @param {String} name134 * @return {Command} the new command135 * @api public136 */137138Command.prototype.command = function(name){139 var args = name.split(/ +/);140 var cmd = new Command(args.shift());141 this.commands.push(cmd);103 cmd.arg(args);142 cmd.parseExpectedArgs(args);143 cmd.parent = this;144 return cmd;145};146147/**148 * Parse expected `args`.149 *150 * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.151 *152 * @param {Array} args153 * @return {Command} for chaining154 * @api public155 */156108Command.prototype.arg = function(args){157Command.prototype.parseExpectedArgs = function(args){158 if (!args.length) return;159 var self = this;160 args.forEach(function(arg){161 switch (arg[0]) {
325 unmodified lines