Skip to content
Myr

Add ability to specify arguments syntax for top-level command

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

* index.js: Add arguments method, support top-level command in action.

authored by Reuben Thomas · committed by Reuben Thomas · parent 070dd26 · Browse files · 2 files+44 added−2 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+44 added−2 removed

  • tests:+30 added−0 removed
  • other:+14 added−2 removed

2 files+44 added−2 removed

added:test/test.arguments.js+30 added
modified:index.js+14 added-2 removed
153 unmodified lines
154 return cmd;155};156157/**158 * Define argument syntax for the top-level command.159 *160 * @api public161 */162163Command.prototype.arguments = function (desc) {164 return this.parseExpectedArgs(desc.split(/ +/));165}166167/**168 * Add an implicit `help [cmd]` subcommand169 * which invokes `--help` for the given command.170 *171 * @api private
84 unmodified lines
256 }257258 fn.apply(this, args);259 };260 var parent = this.parent || this;261 var name = parent === this ? '*' : this._name;250 this.parent.on(this._name, listener);251 if (this._alias) this.parent.on(this._alias, listener);262 parent.on(name, listener);263 if (this._alias) parent.on(this._alias, listener);264 return this;265};266267/**
640 unmodified lines