Skip to content
Myr

Revert "multiline descriptions support"

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

authored by Zhiye Li · committed by Zhiye Li · parent 4dae21d · Browse files · 6 files+6 added−83 removed
This commit

State

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

Diff stats

6 files+6 added−83 removed

  • tests:+0 added−55 removed
  • other:+6 added−28 removed

6 files+6 added−83 removed

modified:examples/pizza+1 added-1 removed
10 unmodified lines
11 .description('An application for pizzas ordering')12 .option('-p, --peppers', 'Add peppers')13 .option('-P, --pineapple', 'Add pineapple')14 .option('-b, --bbq', 'Add bbq sauce')15 .option('-c, --cheese <type>', 'Add the specified type\nof cheese [marble]')15 .option('-c, --cheese <type>', 'Add the specified type of cheese [marble]')16 .option('-C, --no-cheese', 'You do not want any cheese')17 .parse(process.argv);1819console.log('you ordered a pizza with:');
10 unmodified lines
deleted:test/test.command.description.js-27 removed
deleted:test/test.command.usage.description.js-28 removed
modified:index.js+3 added-23 removed
909 unmodified lines
910911 // Prepend the help information912 return [pad('-h, --help', width) + ' ' + 'output usage information']913 .concat(this.options.map(function(option) {914 return pad(option.flags, width) + ' ' + offset(option.description, width + 2);914 return pad(option.flags, width) + ' ' + option.description;915 }))916 .join('\n');917};918
35 unmodified lines
954 ''955 , ' Commands:'956 , ''957 , commands.map(function(cmd) {958 return pad(cmd[0], width) + ' ' + offset(cmd[1], width + 2);958 return pad(cmd[0], width) + ' ' + cmd[1];959 }).join('\n').replace(/^/gm, ' ')960 , ''961 ].join('\n');962};
19 unmodified lines
982 cmdName = cmdName + '|' + this._alias;983 }984 var usage = [985 ''986 ,' Usage: ' + cmdName + ' ' + offset(this.usage(), 9)986 ,' Usage: ' + cmdName + ' ' + this.usage()987 , ''988 ];989990 var cmds = [];
65 unmodified lines
1056 return str + Array(len + 1).join(' ');1057}10581059/**1060 * Prepend to each line of `str` spaced string of `offset` length.1061 *1062 * @param {String} str1063 * @param {Number} offset1064 * @param {Boolean} skipFirstLine1065 * @return {String}1066 * @api private1067 */1068function offset(str, offset, skipFirstLine) {1069 var res = String(str || '').replace(/^/gm, pad('', offset));1070 if (!skipFirstLine) {1071 res = res.replace(/^\s+/, '');1072 }1073 return res;1074}10751076/**1060 * Output help information if necessary1061 *1062 * @param {Command} command to output help for1063 * @param {Array} array of options to search for -h or --help
5 unmodified lines
1069 for (var i = 0; i < options.length; i++) {1070 if (options[i] == '--help' || options[i] == '-h') {1071 cmd.outputHelp();1072 process.exit(0);10901091 // used for test flow only1092 options.splice(i, 1);1073 }1074 }1075}1076
27 unmodified lines
modified:package.json+1 added-2 removed
modified:Readme.md+1 added-2 removed
198 unmodified lines
199 -V, --version output the version number200 -p, --peppers Add peppers201 -P, --pineapple Add pineapple202 -b, --bbq Add bbq sauce203 -c, --cheese <type> Add the specified type204 of cheese [marble]203 -c, --cheese <type> Add the specified type of cheese [marble]204 -C, --no-cheese You do not want any cheese205206```207
135 unmodified lines