exports.Parser.prototype.printHelp = function (options) { if (options.args.length) { util.put(options.args, 1, '--help'); this._commands[options.args[0]]().act(options.args, options); } else { this.printUsage(options); // todo, parse args for deep help if (this._help) this.print('\0cyan(\0bold(' + this._help + '\0)\0)'); this.printCommands(options); this.printOptions(options); this.exit(options); } };
exports.Parser.prototype.printHelp = function (options) { var args = options.args || []; if (args.length) { // parse args for deep help // TODO offer extended help for options if (!util.has(this._commands, args[0])) { this.error(options, util.repr(args[0]) + ' is not a command.'); this.printCommands(options); this.exit(options); } else { util.put(args, 1, '--help'); this._commands[args[0]]().act(args, options); this.exit(options); } } else { this.printUsage(options); if (this._help) this.print('' + this._help + ''); this.printCommands(options); this.printOptions(options); this.exit(options); } };
exports.testPut = function () { var original = [1, 2, 3]; util.put(original, 0, 0); assert.eq([0, 1, 2, 3], original); };