Skip to content
Myr

Use basic types in JSDoc rather than object types (#1178)

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

authored by John Gee · committed by GitHub · parent 28b649d · Browse files · 1 file+57 added−57 removed
This commit

State

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

Diff stats

1 file+57 added−57 removed

  • other:+57 added−57 removed

1 file+57 added−57 removed

modified:index.js+57 added-57 removed
9 unmodified lines
10class Option {11 /**12 * Initialize a new `Option` with the given `flags` and `description`.13 *14 * @param {String} flags15 * @param {String} description14 * @param {string} flags15 * @param {string} description16 * @api public17 */1819 constructor(flags, description) {
10 unmodified lines
3031 /**32 * Return option name.33 *34 * @return {String}34 * @return {string}35 * @api private36 */3738 name() {
3 unmodified lines
42 /**43 * Return option name, in a camelcase format that can be used44 * as a object attribute key.45 *46 * @return {String}46 * @return {string}47 * @api private48 */4950 attributeName() {
2 unmodified lines
5354 /**55 * Check if `arg` matches the short or long flag.56 *57 * @param {String} arg58 * @return {Boolean}57 * @param {string} arg58 * @return {boolean}59 * @api private60 */6162 is(arg) {
7 unmodified lines
70 */71class CommanderError extends Error {72 /**73 * Constructs the CommanderError class74 * @param {Number} exitCode suggested exit code which could be used with process.exit75 * @param {String} code an id string representing the error76 * @param {String} message human-readable description of the error74 * @param {number} exitCode suggested exit code which could be used with process.exit75 * @param {string} code an id string representing the error76 * @param {string} message human-readable description of the error77 * @constructor78 */79 constructor(exitCode, code, message) {80 super(message);
8 unmodified lines
89class Command extends EventEmitter {90 /**91 * Initialize a new `Command`.92 *93 * @param {String} [name]93 * @param {string} [name]94 * @api public95 */9697 constructor(name) {
236 unmodified lines
334335 /**336 * Call process.exit, and _exitCallback if defined.337 *338 * @param {Number} exitCode exit code for using with process.exit339 * @param {String} code an id string representing the error340 * @param {String} message human-readable description of the error338 * @param {number} exitCode exit code for using with process.exit339 * @param {string} code an id string representing the error340 * @param {string} message human-readable description of the error341 * @return never342 * @api private343 */344
52 unmodified lines
397 /**398 * Internal implementation shared by .option() and .requiredOption()399 *400 * @param {Object} config401 * @param {String} flags402 * @param {String} description401 * @param {string} flags402 * @param {string} description403 * @param {Function|*} [fn] - custom option processing function or default vaue404 * @param {*} [defaultValue]405 * @return {Command} for chaining406 * @api private
108 unmodified lines
515 *516 * // optional argument517 * program.option('-c, --cheese [type]', 'add cheese [marble]');518 *519 * @param {String} flags520 * @param {String} description519 * @param {string} flags520 * @param {string} description521 * @param {Function|*} [fn] - custom option processing function or default vaue522 * @param {*} [defaultValue]523 * @return {Command} for chaining524 * @api public
8 unmodified lines
533 * the option must be specified on the command line. (Otherwise the same as .option().)534 *535 * The `flags` string should contain both the short and long flags, separated by comma, a pipe or space.536 *537 * @param {String} flags538 * @param {String} description537 * @param {string} flags538 * @param {string} description539 * @param {Function|*} [fn] - custom option processing function or default vaue540 * @param {*} [defaultValue]541 * @return {Command} for chaining542 * @api public
5 unmodified lines
548549 /**550 * Allow unknown options on the command line.551 *552 * @param {Boolean} arg if `true` or omitted, no error will be thrown552 * @param {Boolean} [arg] - if `true` or omitted, no error will be thrown553 * for unknown options.554 * @api public555 */556 allowUnknownOption(arg) {
34 unmodified lines
591592 /**593 * Store option value594 *595 * @param {String} key595 * @param {string} key596 * @param {Object} value597 * @api private598 */599
7 unmodified lines
607608 /**609 * Retrieve option value610 *611 * @param {String} key611 * @param {string} key612 * @return {Object} value613 * @api private614 */615
293 unmodified lines
909910 /**911 * Return an option matching `arg` if any.912 *913 * @param {String} arg913 * @param {string} arg914 * @return {Option}915 * @api private916 */917
141 unmodified lines
10591060 /**1061 * Argument `name` is missing.1062 *1063 * @param {String} name1063 * @param {string} name1064 * @api private1065 */10661067 missingArgument(name) {
5 unmodified lines
1073 /**1074 * `Option` is missing an argument, but received `flag` or nothing.1075 *1076 * @param {Option} option1077 * @param {String} [flag]1077 * @param {string} [flag]1078 * @api private1079 */10801081 optionMissingArgument(option, flag) {
22 unmodified lines
11041105 /**1106 * Unknown option `flag`.1107 *1108 * @param {String} flag1108 * @param {string} flag1109 * @api private1110 */11111112 unknownOption(flag) {
5 unmodified lines
11181119 /**1120 * Unknown command.1121 *1122 * @param {String} flag1122 * @param {string} flag1123 * @api private1124 */11251126 unknownCommand() {
14 unmodified lines
1141 * which will print the version number when passed.1142 *1143 * You can optionally supply the flags and description to override the defaults.1144 *1145 * @param {String} str1146 * @param {String} [flags]1147 * @param {String} [description]1145 * @param {string} str1146 * @param {string} [flags]1147 * @param {string} [description]1148 * @return {Command} for chaining1149 * @api public1150 */1151
14 unmodified lines
11661167 /**1168 * Set the description to `str`.1169 *1170 * @param {String} str1170 * @param {string} str1171 * @param {Object} [argsDescription]1172 * @return {String|Command}1173 * @api public1174 */
7 unmodified lines
11821183 /**1184 * Set an alias for the command1185 *1186 * @param {String} alias1186 * @param {string} alias1187 * @return {String|Command}1188 * @api public1189 */1190
13 unmodified lines
12041205 /**1206 * Set / get the command usage `str`.1207 *1208 * @param {String} [str]1208 * @param {string} [str]1209 * @return {String|Command}1210 * @api public1211 */1212
14 unmodified lines
12271228 /**1229 * Get or set the name of the command1230 *1231 * @param {String} [str]1231 * @param {string} [str]1232 * @return {String|Command}1233 * @api public1234 */1235
35 unmodified lines
12711272 /**1273 * Return the largest command length.1274 *1275 * @return {Number}1275 * @return {number}1276 * @api private1277 */12781279 largestCommandLength() {
5 unmodified lines
12851286 /**1287 * Return the largest option length.1288 *1289 * @return {Number}1289 * @return {number}1290 * @api private1291 */12921293 largestOptionLength() {
9 unmodified lines
13031304 /**1305 * Return the largest arg length.1306 *1307 * @return {Number}1307 * @return {number}1308 * @api private1309 */13101311 largestArgLength() {
4 unmodified lines
13161317 /**1318 * Return the pad width.1319 *1320 * @return {Number}1320 * @return {number}1321 * @api private1322 */13231324 padWidth() {
15 unmodified lines
13401341 /**1342 * Return help for options.1343 *1344 * @return {String}1344 * @return {string}1345 * @api private1346 */13471348 optionHelp() {
13 unmodified lines
13621363 /**1364 * Return command help documentation.1365 *1366 * @return {String}1366 * @return {string}1367 * @api private1368 */13691370 commandHelp() {
17 unmodified lines
13881389 /**1390 * Return program help documentation.1391 *1392 * @return {String}1392 * @return {string}1393 * @api public1394 */13951396 helpInformation() {
74 unmodified lines
1471 /**1472 * You can pass in flags and a description to override the help1473 * flags and help description for your command.1474 *1475 * @param {String} [flags]1476 * @param {String} [description]1475 * @param {string} [flags]1476 * @param {string} [description]1477 * @return {Command}1478 * @api public1479 */1480
53 unmodified lines
15341535/**1536 * Camel-case the given `flag`1537 *1538 * @param {String} flag1539 * @return {String}1538 * @param {string} flag1539 * @return {string}1540 * @api private1541 */15421543function camelcase(flag) {
4 unmodified lines
15481549/**1550 * Pad `str` to `width`.1551 *1552 * @param {String} str1553 * @param {Number} width1554 * @return {String}1552 * @param {string} str1553 * @param {number} width1554 * @return {string}1555 * @api private1556 */15571558function pad(str, width) {
4 unmodified lines
1563/**1564 * Wraps the given string with line breaks at the specified width while breaking1565 * words and indenting every but the first line on the left.1566 *1567 * @param {String} str1568 * @param {Number} width1569 * @param {Number} indent1570 * @return {String}1567 * @param {string} str1568 * @param {number} width1569 * @param {number} indent1570 * @return {string}1571 * @api private1572 */1573function wrap(str, width, indent) {1574 const regex = new RegExp('.{1,' + (width - 1) + '}([\\s\u200B]|$)|[^\\s\u200B]+?([\\s\u200B]|$)', 'g');
10 unmodified lines
1585 * Optionally wrap the given str to a max width of width characters per line1586 * while indenting with indent spaces. Do not wrap if insufficient width or1587 * string is manually formatted.1588 *1589 * @param {String} str1590 * @param {Number} width1591 * @param {Number} indent1592 * @return {String}1589 * @param {string} str1590 * @param {number} width1591 * @param {number} indent1592 * @return {string}1593 * @api private1594 */1595function optionalWrap(str, width, indent) {1596 // Detect manually wrapped and indented strings by searching for line breaks
26 unmodified lines
1623/**1624 * Takes an argument and returns its human readable equivalent for help usage.1625 *1626 * @param {Object} arg1627 * @return {String}1627 * @return {string}1628 * @api private1629 */16301631function humanReadableArgName(arg) {
53 unmodified lines