bililive-cli 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs CHANGED
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var EventEmitter$1 = require('node:events');
5
- var require$$1 = require('node:child_process');
6
- var path$1 = require('node:path');
4
+ var require$$0 = require('events');
5
+ var require$$0$1 = require('child_process');
6
+ var require$$1 = require('path');
7
+ var require$$0$2 = require('fs');
8
+ var require$$4 = require('process');
7
9
  var fs$1 = require('node:fs');
8
- var process$2 = require('node:process');
9
10
  var os = require('node:os');
11
+ var path$1 = require('node:path');
10
12
 
11
13
  var commander = {};
12
14
 
@@ -16,6 +18,7 @@ var error = {};
16
18
 
17
19
  /**
18
20
  * CommanderError class
21
+ * @class
19
22
  */
20
23
 
21
24
  let CommanderError$3 = class CommanderError extends Error {
@@ -24,6 +27,7 @@ let CommanderError$3 = class CommanderError extends Error {
24
27
  * @param {number} exitCode suggested exit code which could be used with process.exit
25
28
  * @param {string} code an id string representing the error
26
29
  * @param {string} message human-readable description of the error
30
+ * @constructor
27
31
  */
28
32
  constructor(exitCode, code, message) {
29
33
  super(message);
@@ -38,11 +42,13 @@ let CommanderError$3 = class CommanderError extends Error {
38
42
 
39
43
  /**
40
44
  * InvalidArgumentError class
45
+ * @class
41
46
  */
42
47
  let InvalidArgumentError$4 = class InvalidArgumentError extends CommanderError$3 {
43
48
  /**
44
49
  * Constructs the InvalidArgumentError class
45
50
  * @param {string} [message] explanation of why argument is invalid
51
+ * @constructor
46
52
  */
47
53
  constructor(message) {
48
54
  super(1, 'commander.invalidArgument', message);
@@ -107,7 +113,7 @@ let Argument$3 = class Argument {
107
113
  }
108
114
 
109
115
  /**
110
- * @package
116
+ * @package internal use only
111
117
  */
112
118
 
113
119
  _concatValue(value, previous) {
@@ -155,9 +161,7 @@ let Argument$3 = class Argument {
155
161
  this.argChoices = values.slice();
156
162
  this.parseArg = (arg, previous) => {
157
163
  if (!this.argChoices.includes(arg)) {
158
- throw new InvalidArgumentError$3(
159
- `Allowed choices are ${this.argChoices.join(', ')}.`,
160
- );
164
+ throw new InvalidArgumentError$3(`Allowed choices are ${this.argChoices.join(', ')}.`);
161
165
  }
162
166
  if (this.variadic) {
163
167
  return this._concatValue(arg, previous);
@@ -169,8 +173,6 @@ let Argument$3 = class Argument {
169
173
 
170
174
  /**
171
175
  * Make argument required.
172
- *
173
- * @returns {Argument}
174
176
  */
175
177
  argRequired() {
176
178
  this.required = true;
@@ -179,8 +181,6 @@ let Argument$3 = class Argument {
179
181
 
180
182
  /**
181
183
  * Make argument optional.
182
- *
183
- * @returns {Argument}
184
184
  */
185
185
  argOptional() {
186
186
  this.required = false;
@@ -199,7 +199,9 @@ let Argument$3 = class Argument {
199
199
  function humanReadableArgName$2(arg) {
200
200
  const nameOutput = arg.name() + (arg.variadic === true ? '...' : '');
201
201
 
202
- return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
202
+ return arg.required
203
+ ? '<' + nameOutput + '>'
204
+ : '[' + nameOutput + ']';
203
205
  }
204
206
 
205
207
  argument.Argument = Argument$3;
@@ -236,14 +238,14 @@ let Help$3 = class Help {
236
238
  */
237
239
 
238
240
  visibleCommands(cmd) {
239
- const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
241
+ const visibleCommands = cmd.commands.filter(cmd => !cmd._hidden);
240
242
  const helpCommand = cmd._getHelpCommand();
241
243
  if (helpCommand && !helpCommand._hidden) {
242
244
  visibleCommands.push(helpCommand);
243
245
  }
244
246
  if (this.sortSubcommands) {
245
247
  visibleCommands.sort((a, b) => {
246
- // @ts-ignore: because overloaded return type
248
+ // @ts-ignore: overloaded return type
247
249
  return a.name().localeCompare(b.name());
248
250
  });
249
251
  }
@@ -255,14 +257,12 @@ let Help$3 = class Help {
255
257
  *
256
258
  * @param {Option} a
257
259
  * @param {Option} b
258
- * @returns {number}
260
+ * @returns number
259
261
  */
260
262
  compareOptions(a, b) {
261
263
  const getSortKey = (option) => {
262
264
  // WYSIWYG for order displayed in help. Short used for comparison if present. No special handling for negated.
263
- return option.short
264
- ? option.short.replace(/^-/, '')
265
- : option.long.replace(/^--/, '');
265
+ return option.short ? option.short.replace(/^-/, '') : option.long.replace(/^--/, '');
266
266
  };
267
267
  return getSortKey(a).localeCompare(getSortKey(b));
268
268
  }
@@ -285,13 +285,9 @@ let Help$3 = class Help {
285
285
  if (!removeShort && !removeLong) {
286
286
  visibleOptions.push(helpOption); // no changes needed
287
287
  } else if (helpOption.long && !removeLong) {
288
- visibleOptions.push(
289
- cmd.createOption(helpOption.long, helpOption.description),
290
- );
288
+ visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
291
289
  } else if (helpOption.short && !removeShort) {
292
- visibleOptions.push(
293
- cmd.createOption(helpOption.short, helpOption.description),
294
- );
290
+ visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
295
291
  }
296
292
  }
297
293
  if (this.sortOptions) {
@@ -311,14 +307,8 @@ let Help$3 = class Help {
311
307
  if (!this.showGlobalOptions) return [];
312
308
 
313
309
  const globalOptions = [];
314
- for (
315
- let ancestorCmd = cmd.parent;
316
- ancestorCmd;
317
- ancestorCmd = ancestorCmd.parent
318
- ) {
319
- const visibleOptions = ancestorCmd.options.filter(
320
- (option) => !option.hidden,
321
- );
310
+ for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
311
+ const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
322
312
  globalOptions.push(...visibleOptions);
323
313
  }
324
314
  if (this.sortOptions) {
@@ -337,14 +327,13 @@ let Help$3 = class Help {
337
327
  visibleArguments(cmd) {
338
328
  // Side effect! Apply the legacy descriptions before the arguments are displayed.
339
329
  if (cmd._argsDescription) {
340
- cmd.registeredArguments.forEach((argument) => {
341
- argument.description =
342
- argument.description || cmd._argsDescription[argument.name()] || '';
330
+ cmd.registeredArguments.forEach(argument => {
331
+ argument.description = argument.description || cmd._argsDescription[argument.name()] || '';
343
332
  });
344
333
  }
345
334
 
346
335
  // If there are any arguments with a description then return all the arguments.
347
- if (cmd.registeredArguments.find((argument) => argument.description)) {
336
+ if (cmd.registeredArguments.find(argument => argument.description)) {
348
337
  return cmd.registeredArguments;
349
338
  }
350
339
  return [];
@@ -359,15 +348,11 @@ let Help$3 = class Help {
359
348
 
360
349
  subcommandTerm(cmd) {
361
350
  // Legacy. Ignores custom usage string, and nested commands.
362
- const args = cmd.registeredArguments
363
- .map((arg) => humanReadableArgName$1(arg))
364
- .join(' ');
365
- return (
366
- cmd._name +
351
+ const args = cmd.registeredArguments.map(arg => humanReadableArgName$1(arg)).join(' ');
352
+ return cmd._name +
367
353
  (cmd._aliases[0] ? '|' + cmd._aliases[0] : '') +
368
354
  (cmd.options.length ? ' [options]' : '') + // simplistic check for non-help option
369
- (args ? ' ' + args : '')
370
- );
355
+ (args ? ' ' + args : '');
371
356
  }
372
357
 
373
358
  /**
@@ -462,11 +447,7 @@ let Help$3 = class Help {
462
447
  cmdName = cmdName + '|' + cmd._aliases[0];
463
448
  }
464
449
  let ancestorCmdNames = '';
465
- for (
466
- let ancestorCmd = cmd.parent;
467
- ancestorCmd;
468
- ancestorCmd = ancestorCmd.parent
469
- ) {
450
+ for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
470
451
  ancestorCmdNames = ancestorCmd.name() + ' ' + ancestorCmdNames;
471
452
  }
472
453
  return ancestorCmdNames + cmdName + ' ' + cmd.usage();
@@ -480,7 +461,7 @@ let Help$3 = class Help {
480
461
  */
481
462
 
482
463
  commandDescription(cmd) {
483
- // @ts-ignore: because overloaded return type
464
+ // @ts-ignore: overloaded return type
484
465
  return cmd.description();
485
466
  }
486
467
 
@@ -493,7 +474,7 @@ let Help$3 = class Help {
493
474
  */
494
475
 
495
476
  subcommandDescription(cmd) {
496
- // @ts-ignore: because overloaded return type
477
+ // @ts-ignore: overloaded return type
497
478
  return cmd.summary() || cmd.description();
498
479
  }
499
480
 
@@ -510,20 +491,15 @@ let Help$3 = class Help {
510
491
  if (option.argChoices) {
511
492
  extraInfo.push(
512
493
  // use stringify to match the display of the default value
513
- `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,
514
- );
494
+ `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`);
515
495
  }
516
496
  if (option.defaultValue !== undefined) {
517
497
  // default for boolean and negated more for programmer than end user,
518
498
  // but show true/false for boolean option as may be for hand-rolled env or config processing.
519
- const showDefault =
520
- option.required ||
521
- option.optional ||
499
+ const showDefault = option.required || option.optional ||
522
500
  (option.isBoolean() && typeof option.defaultValue === 'boolean');
523
501
  if (showDefault) {
524
- extraInfo.push(
525
- `default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`,
526
- );
502
+ extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
527
503
  }
528
504
  }
529
505
  // preset for boolean and negated are more for programmer than end user
@@ -552,13 +528,10 @@ let Help$3 = class Help {
552
528
  if (argument.argChoices) {
553
529
  extraInfo.push(
554
530
  // use stringify to match the display of the default value
555
- `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,
556
- );
531
+ `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`);
557
532
  }
558
533
  if (argument.defaultValue !== undefined) {
559
- extraInfo.push(
560
- `default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`,
561
- );
534
+ extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
562
535
  }
563
536
  if (extraInfo.length > 0) {
564
537
  const extraDescripton = `(${extraInfo.join(', ')})`;
@@ -586,11 +559,7 @@ let Help$3 = class Help {
586
559
  function formatItem(term, description) {
587
560
  if (description) {
588
561
  const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
589
- return helper.wrap(
590
- fullText,
591
- helpWidth - itemIndentWidth,
592
- termWidth + itemSeparatorWidth,
593
- );
562
+ return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
594
563
  }
595
564
  return term;
596
565
  }
@@ -604,18 +573,12 @@ let Help$3 = class Help {
604
573
  // Description
605
574
  const commandDescription = helper.commandDescription(cmd);
606
575
  if (commandDescription.length > 0) {
607
- output = output.concat([
608
- helper.wrap(commandDescription, helpWidth, 0),
609
- '',
610
- ]);
576
+ output = output.concat([helper.wrap(commandDescription, helpWidth, 0), '']);
611
577
  }
612
578
 
613
579
  // Arguments
614
580
  const argumentList = helper.visibleArguments(cmd).map((argument) => {
615
- return formatItem(
616
- helper.argumentTerm(argument),
617
- helper.argumentDescription(argument),
618
- );
581
+ return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
619
582
  });
620
583
  if (argumentList.length > 0) {
621
584
  output = output.concat(['Arguments:', formatList(argumentList), '']);
@@ -623,39 +586,24 @@ let Help$3 = class Help {
623
586
 
624
587
  // Options
625
588
  const optionList = helper.visibleOptions(cmd).map((option) => {
626
- return formatItem(
627
- helper.optionTerm(option),
628
- helper.optionDescription(option),
629
- );
589
+ return formatItem(helper.optionTerm(option), helper.optionDescription(option));
630
590
  });
631
591
  if (optionList.length > 0) {
632
592
  output = output.concat(['Options:', formatList(optionList), '']);
633
593
  }
634
594
 
635
595
  if (this.showGlobalOptions) {
636
- const globalOptionList = helper
637
- .visibleGlobalOptions(cmd)
638
- .map((option) => {
639
- return formatItem(
640
- helper.optionTerm(option),
641
- helper.optionDescription(option),
642
- );
643
- });
596
+ const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
597
+ return formatItem(helper.optionTerm(option), helper.optionDescription(option));
598
+ });
644
599
  if (globalOptionList.length > 0) {
645
- output = output.concat([
646
- 'Global Options:',
647
- formatList(globalOptionList),
648
- '',
649
- ]);
600
+ output = output.concat(['Global Options:', formatList(globalOptionList), '']);
650
601
  }
651
602
  }
652
603
 
653
604
  // Commands
654
605
  const commandList = helper.visibleCommands(cmd).map((cmd) => {
655
- return formatItem(
656
- helper.subcommandTerm(cmd),
657
- helper.subcommandDescription(cmd),
658
- );
606
+ return formatItem(helper.subcommandTerm(cmd), helper.subcommandDescription(cmd));
659
607
  });
660
608
  if (commandList.length > 0) {
661
609
  output = output.concat(['Commands:', formatList(commandList), '']);
@@ -677,7 +625,7 @@ let Help$3 = class Help {
677
625
  helper.longestOptionTermLength(cmd, helper),
678
626
  helper.longestGlobalOptionTermLength(cmd, helper),
679
627
  helper.longestSubcommandTermLength(cmd, helper),
680
- helper.longestArgumentTermLength(cmd, helper),
628
+ helper.longestArgumentTermLength(cmd, helper)
681
629
  );
682
630
  }
683
631
 
@@ -695,8 +643,7 @@ let Help$3 = class Help {
695
643
 
696
644
  wrap(str, width, indent, minColumnWidth = 40) {
697
645
  // Full \s characters, minus the linefeeds.
698
- const indents =
699
- ' \\f\\t\\v\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff';
646
+ const indents = ' \\f\\t\\v\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff';
700
647
  // Detect manually wrapped and indented strings by searching for line break followed by spaces.
701
648
  const manualIndent = new RegExp(`[\\n][${indents}]+`);
702
649
  if (str.match(manualIndent)) return str;
@@ -711,20 +658,12 @@ let Help$3 = class Help {
711
658
  const breaks = `\\s${zeroWidthSpace}`;
712
659
  // Match line end (so empty lines don't collapse),
713
660
  // or as much text as will fit in column, or excess text up to first break.
714
- const regex = new RegExp(
715
- `\n|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`,
716
- 'g',
717
- );
661
+ const regex = new RegExp(`\n|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, 'g');
718
662
  const lines = columnText.match(regex) || [];
719
- return (
720
- leadingStr +
721
- lines
722
- .map((line, i) => {
723
- if (line === '\n') return ''; // preserve empty lines
724
- return (i > 0 ? indentString : '') + line.trimEnd();
725
- })
726
- .join('\n')
727
- );
663
+ return leadingStr + lines.map((line, i) => {
664
+ if (line === '\n') return ''; // preserve empty lines
665
+ return ((i > 0) ? indentString : '') + line.trimEnd();
666
+ }).join('\n');
728
667
  }
729
668
  };
730
669
 
@@ -827,7 +766,7 @@ let Option$3 = class Option {
827
766
  * .addOption(new Option('--log', 'write logging information to file'))
828
767
  * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
829
768
  *
830
- * @param {object} impliedOptionValues
769
+ * @param {Object} impliedOptionValues
831
770
  * @return {Option}
832
771
  */
833
772
  implies(impliedOptionValues) {
@@ -892,7 +831,7 @@ let Option$3 = class Option {
892
831
  }
893
832
 
894
833
  /**
895
- * @package
834
+ * @package internal use only
896
835
  */
897
836
 
898
837
  _concatValue(value, previous) {
@@ -914,9 +853,7 @@ let Option$3 = class Option {
914
853
  this.argChoices = values.slice();
915
854
  this.parseArg = (arg, previous) => {
916
855
  if (!this.argChoices.includes(arg)) {
917
- throw new InvalidArgumentError$2(
918
- `Allowed choices are ${this.argChoices.join(', ')}.`,
919
- );
856
+ throw new InvalidArgumentError$2(`Allowed choices are ${this.argChoices.join(', ')}.`);
920
857
  }
921
858
  if (this.variadic) {
922
859
  return this._concatValue(arg, previous);
@@ -955,7 +892,7 @@ let Option$3 = class Option {
955
892
  *
956
893
  * @param {string} arg
957
894
  * @return {boolean}
958
- * @package
895
+ * @package internal use only
959
896
  */
960
897
 
961
898
  is(arg) {
@@ -968,7 +905,7 @@ let Option$3 = class Option {
968
905
  * Options are one of boolean, negated, required argument, or optional argument.
969
906
  *
970
907
  * @return {boolean}
971
- * @package
908
+ * @package internal use only
972
909
  */
973
910
 
974
911
  isBoolean() {
@@ -991,7 +928,7 @@ let DualOptions$1 = class DualOptions {
991
928
  this.positiveOptions = new Map();
992
929
  this.negativeOptions = new Map();
993
930
  this.dualOptions = new Set();
994
- options.forEach((option) => {
931
+ options.forEach(option => {
995
932
  if (option.negate) {
996
933
  this.negativeOptions.set(option.attributeName(), option);
997
934
  } else {
@@ -1018,7 +955,7 @@ let DualOptions$1 = class DualOptions {
1018
955
 
1019
956
  // Use the value to deduce if (probably) came from the option.
1020
957
  const preset = this.negativeOptions.get(optionKey).presetArg;
1021
- const negativeValue = preset !== undefined ? preset : false;
958
+ const negativeValue = (preset !== undefined) ? preset : false;
1022
959
  return option.negate === (negativeValue === value);
1023
960
  }
1024
961
  };
@@ -1049,8 +986,7 @@ function splitOptionFlags(flags) {
1049
986
  // Use original very loose parsing to maintain backwards compatibility for now,
1050
987
  // which allowed for example unintended `-sw, --short-word` [sic].
1051
988
  const flagParts = flags.split(/[ |,]+/);
1052
- if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
1053
- shortFlag = flagParts.shift();
989
+ if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1])) shortFlag = flagParts.shift();
1054
990
  longFlag = flagParts.shift();
1055
991
  // Add support for lone short flag without significantly changing parsing!
1056
992
  if (!shortFlag && /^-[^-]$/.test(longFlag)) {
@@ -1073,8 +1009,7 @@ function editDistance(a, b) {
1073
1009
  // (Simple implementation.)
1074
1010
 
1075
1011
  // Quick early exit, return worst case.
1076
- if (Math.abs(a.length - b.length) > maxDistance)
1077
- return Math.max(a.length, b.length);
1012
+ if (Math.abs(a.length - b.length) > maxDistance) return Math.max(a.length, b.length);
1078
1013
 
1079
1014
  // distance between prefix substrings of a and b
1080
1015
  const d = [];
@@ -1100,7 +1035,7 @@ function editDistance(a, b) {
1100
1035
  d[i][j] = Math.min(
1101
1036
  d[i - 1][j] + 1, // deletion
1102
1037
  d[i][j - 1] + 1, // insertion
1103
- d[i - 1][j - 1] + cost, // substitution
1038
+ d[i - 1][j - 1] + cost // substitution
1104
1039
  );
1105
1040
  // transposition
1106
1041
  if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
@@ -1128,7 +1063,7 @@ function suggestSimilar$1(word, candidates) {
1128
1063
  const searchingOptions = word.startsWith('--');
1129
1064
  if (searchingOptions) {
1130
1065
  word = word.slice(2);
1131
- candidates = candidates.map((candidate) => candidate.slice(2));
1066
+ candidates = candidates.map(candidate => candidate.slice(2));
1132
1067
  }
1133
1068
 
1134
1069
  let similar = [];
@@ -1153,7 +1088,7 @@ function suggestSimilar$1(word, candidates) {
1153
1088
 
1154
1089
  similar.sort((a, b) => a.localeCompare(b));
1155
1090
  if (searchingOptions) {
1156
- similar = similar.map((candidate) => `--${candidate}`);
1091
+ similar = similar.map(candidate => `--${candidate}`);
1157
1092
  }
1158
1093
 
1159
1094
  if (similar.length > 1) {
@@ -1167,11 +1102,11 @@ function suggestSimilar$1(word, candidates) {
1167
1102
 
1168
1103
  suggestSimilar$2.suggestSimilar = suggestSimilar$1;
1169
1104
 
1170
- const EventEmitter = EventEmitter$1.EventEmitter;
1171
- const childProcess = require$$1;
1172
- const path = path$1;
1173
- const fs = fs$1;
1174
- const process$1 = process$2;
1105
+ const EventEmitter = require$$0.EventEmitter;
1106
+ const childProcess = require$$0$1;
1107
+ const path = require$$1;
1108
+ const fs = require$$0$2;
1109
+ const process$1 = require$$4;
1175
1110
 
1176
1111
  const { Argument: Argument$2, humanReadableArgName } = argument;
1177
1112
  const { CommanderError: CommanderError$2 } = error;
@@ -1229,11 +1164,9 @@ let Command$2 = class Command extends EventEmitter {
1229
1164
  this._outputConfiguration = {
1230
1165
  writeOut: (str) => process$1.stdout.write(str),
1231
1166
  writeErr: (str) => process$1.stderr.write(str),
1232
- getOutHelpWidth: () =>
1233
- process$1.stdout.isTTY ? process$1.stdout.columns : undefined,
1234
- getErrHelpWidth: () =>
1235
- process$1.stderr.isTTY ? process$1.stderr.columns : undefined,
1236
- outputError: (str, write) => write(str),
1167
+ getOutHelpWidth: () => process$1.stdout.isTTY ? process$1.stdout.columns : undefined,
1168
+ getErrHelpWidth: () => process$1.stderr.isTTY ? process$1.stderr.columns : undefined,
1169
+ outputError: (str, write) => write(str)
1237
1170
  };
1238
1171
 
1239
1172
  this._hidden = false;
@@ -1260,8 +1193,7 @@ let Command$2 = class Command extends EventEmitter {
1260
1193
  this._helpConfiguration = sourceCommand._helpConfiguration;
1261
1194
  this._exitCallback = sourceCommand._exitCallback;
1262
1195
  this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
1263
- this._combineFlagAndOptionalValue =
1264
- sourceCommand._combineFlagAndOptionalValue;
1196
+ this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
1265
1197
  this._allowExcessArguments = sourceCommand._allowExcessArguments;
1266
1198
  this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
1267
1199
  this._showHelpAfterError = sourceCommand._showHelpAfterError;
@@ -1277,7 +1209,6 @@ let Command$2 = class Command extends EventEmitter {
1277
1209
 
1278
1210
  _getCommandAndAncestors() {
1279
1211
  const result = [];
1280
- // eslint-disable-next-line @typescript-eslint/no-this-alias
1281
1212
  for (let command = this; command; command = command.parent) {
1282
1213
  result.push(command);
1283
1214
  }
@@ -1304,8 +1235,8 @@ let Command$2 = class Command extends EventEmitter {
1304
1235
  * .command('stop [service]', 'stop named service, or all if no name supplied');
1305
1236
  *
1306
1237
  * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
1307
- * @param {(object | string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
1308
- * @param {object} [execOpts] - configuration options (for executable)
1238
+ * @param {(Object|string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
1239
+ * @param {Object} [execOpts] - configuration options (for executable)
1309
1240
  * @return {Command} returns new command for action handler, or `this` for executable command
1310
1241
  */
1311
1242
 
@@ -1365,8 +1296,8 @@ let Command$2 = class Command extends EventEmitter {
1365
1296
  * You can customise the help by overriding Help properties using configureHelp(),
1366
1297
  * or with a subclass of Help by overriding createHelp().
1367
1298
  *
1368
- * @param {object} [configuration] - configuration options
1369
- * @return {(Command | object)} `this` command for chaining, or stored configuration
1299
+ * @param {Object} [configuration] - configuration options
1300
+ * @return {(Command|Object)} `this` command for chaining, or stored configuration
1370
1301
  */
1371
1302
 
1372
1303
  configureHelp(configuration) {
@@ -1391,8 +1322,8 @@ let Command$2 = class Command extends EventEmitter {
1391
1322
  * // functions based on what is being written out
1392
1323
  * outputError(str, write) // used for displaying errors, and not used for displaying help
1393
1324
  *
1394
- * @param {object} [configuration] - configuration options
1395
- * @return {(Command | object)} `this` command for chaining, or stored configuration
1325
+ * @param {Object} [configuration] - configuration options
1326
+ * @return {(Command|Object)} `this` command for chaining, or stored configuration
1396
1327
  */
1397
1328
 
1398
1329
  configureOutput(configuration) {
@@ -1431,7 +1362,7 @@ let Command$2 = class Command extends EventEmitter {
1431
1362
  * See .command() for creating an attached subcommand which inherits settings from its parent.
1432
1363
  *
1433
1364
  * @param {Command} cmd - new subcommand
1434
- * @param {object} [opts] - configuration options
1365
+ * @param {Object} [opts] - configuration options
1435
1366
  * @return {Command} `this` command for chaining
1436
1367
  */
1437
1368
 
@@ -1507,12 +1438,9 @@ let Command$2 = class Command extends EventEmitter {
1507
1438
  */
1508
1439
 
1509
1440
  arguments(names) {
1510
- names
1511
- .trim()
1512
- .split(/ +/)
1513
- .forEach((detail) => {
1514
- this.argument(detail);
1515
- });
1441
+ names.trim().split(/ +/).forEach((detail) => {
1442
+ this.argument(detail);
1443
+ });
1516
1444
  return this;
1517
1445
  }
1518
1446
 
@@ -1525,18 +1453,10 @@ let Command$2 = class Command extends EventEmitter {
1525
1453
  addArgument(argument) {
1526
1454
  const previousArgument = this.registeredArguments.slice(-1)[0];
1527
1455
  if (previousArgument && previousArgument.variadic) {
1528
- throw new Error(
1529
- `only the last argument can be variadic '${previousArgument.name()}'`,
1530
- );
1456
+ throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
1531
1457
  }
1532
- if (
1533
- argument.required &&
1534
- argument.defaultValue !== undefined &&
1535
- argument.parseArg === undefined
1536
- ) {
1537
- throw new Error(
1538
- `a default value for a required argument is never used: '${argument.name()}'`,
1539
- );
1458
+ if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) {
1459
+ throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
1540
1460
  }
1541
1461
  this.registeredArguments.push(argument);
1542
1462
  return this;
@@ -1545,7 +1465,6 @@ let Command$2 = class Command extends EventEmitter {
1545
1465
  /**
1546
1466
  * Customise or override default help command. By default a help command is automatically added if your command has subcommands.
1547
1467
  *
1548
- * @example
1549
1468
  * program.helpCommand('help [cmd]');
1550
1469
  * program.helpCommand('help [cmd]', 'show help');
1551
1470
  * program.helpCommand(false); // suppress default help command
@@ -1604,11 +1523,8 @@ let Command$2 = class Command extends EventEmitter {
1604
1523
  * @package
1605
1524
  */
1606
1525
  _getHelpCommand() {
1607
- const hasImplicitHelpCommand =
1608
- this._addImplicitHelpCommand ??
1609
- (this.commands.length &&
1610
- !this._actionHandler &&
1611
- !this._findCommand('help'));
1526
+ const hasImplicitHelpCommand = this._addImplicitHelpCommand ??
1527
+ (this.commands.length && !this._actionHandler && !this._findCommand('help'));
1612
1528
 
1613
1529
  if (hasImplicitHelpCommand) {
1614
1530
  if (this._helpCommand === undefined) {
@@ -1754,18 +1670,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
1754
1670
  * Register option if no conflicts found, or throw on conflict.
1755
1671
  *
1756
1672
  * @param {Option} option
1757
- * @private
1673
+ * @api private
1758
1674
  */
1759
1675
 
1760
1676
  _registerOption(option) {
1761
- const matchingOption =
1762
- (option.short && this._findOption(option.short)) ||
1677
+ const matchingOption = (option.short && this._findOption(option.short)) ||
1763
1678
  (option.long && this._findOption(option.long));
1764
1679
  if (matchingOption) {
1765
- const matchingFlag =
1766
- option.long && this._findOption(option.long)
1767
- ? option.long
1768
- : option.short;
1680
+ const matchingFlag = (option.long && this._findOption(option.long)) ? option.long : option.short;
1769
1681
  throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
1770
1682
  - already used by option '${matchingOption.flags}'`);
1771
1683
  }
@@ -1778,7 +1690,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1778
1690
  * Register command if no conflicts found, or throw on conflict.
1779
1691
  *
1780
1692
  * @param {Command} command
1781
- * @private
1693
+ * @api private
1782
1694
  */
1783
1695
 
1784
1696
  _registerCommand(command) {
@@ -1786,15 +1698,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1786
1698
  return [cmd.name()].concat(cmd.aliases());
1787
1699
  };
1788
1700
 
1789
- const alreadyUsed = knownBy(command).find((name) =>
1790
- this._findCommand(name),
1791
- );
1701
+ const alreadyUsed = knownBy(command).find((name) => this._findCommand(name));
1792
1702
  if (alreadyUsed) {
1793
1703
  const existingCmd = knownBy(this._findCommand(alreadyUsed)).join('|');
1794
1704
  const newCmd = knownBy(command).join('|');
1795
- throw new Error(
1796
- `cannot add command '${newCmd}' as already have command '${existingCmd}'`,
1797
- );
1705
+ throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
1798
1706
  }
1799
1707
 
1800
1708
  this.commands.push(command);
@@ -1817,11 +1725,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1817
1725
  // --no-foo is special and defaults foo to true, unless a --foo option is already defined
1818
1726
  const positiveLongFlag = option.long.replace(/^--no-/, '--');
1819
1727
  if (!this._findOption(positiveLongFlag)) {
1820
- this.setOptionValueWithSource(
1821
- name,
1822
- option.defaultValue === undefined ? true : option.defaultValue,
1823
- 'default',
1824
- );
1728
+ this.setOptionValueWithSource(name, option.defaultValue === undefined ? true : option.defaultValue, 'default');
1825
1729
  }
1826
1730
  } else if (option.defaultValue !== undefined) {
1827
1731
  this.setOptionValueWithSource(name, option.defaultValue, 'default');
@@ -1874,14 +1778,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1874
1778
  /**
1875
1779
  * Internal implementation shared by .option() and .requiredOption()
1876
1780
  *
1877
- * @return {Command} `this` command for chaining
1878
1781
  * @private
1879
1782
  */
1880
1783
  _optionEx(config, flags, description, fn, defaultValue) {
1881
1784
  if (typeof flags === 'object' && flags instanceof Option$2) {
1882
- throw new Error(
1883
- 'To add an Option object use addOption() instead of option() or requiredOption()',
1884
- );
1785
+ throw new Error('To add an Option object use addOption() instead of option() or requiredOption()');
1885
1786
  }
1886
1787
  const option = this.createOption(flags, description);
1887
1788
  option.makeOptionMandatory(!!config.mandatory);
@@ -1929,26 +1830,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
1929
1830
  }
1930
1831
 
1931
1832
  /**
1932
- * Add a required option which must have a value after parsing. This usually means
1933
- * the option must be specified on the command line. (Otherwise the same as .option().)
1934
- *
1935
- * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
1936
- *
1937
- * @param {string} flags
1938
- * @param {string} [description]
1939
- * @param {(Function|*)} [parseArg] - custom option processing function or default value
1940
- * @param {*} [defaultValue]
1941
- * @return {Command} `this` command for chaining
1942
- */
1833
+ * Add a required option which must have a value after parsing. This usually means
1834
+ * the option must be specified on the command line. (Otherwise the same as .option().)
1835
+ *
1836
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
1837
+ *
1838
+ * @param {string} flags
1839
+ * @param {string} [description]
1840
+ * @param {(Function|*)} [parseArg] - custom option processing function or default value
1841
+ * @param {*} [defaultValue]
1842
+ * @return {Command} `this` command for chaining
1843
+ */
1943
1844
 
1944
1845
  requiredOption(flags, description, parseArg, defaultValue) {
1945
- return this._optionEx(
1946
- { mandatory: true },
1947
- flags,
1948
- description,
1949
- parseArg,
1950
- defaultValue,
1951
- );
1846
+ return this._optionEx({ mandatory: true }, flags, description, parseArg, defaultValue);
1952
1847
  }
1953
1848
 
1954
1849
  /**
@@ -1959,8 +1854,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1959
1854
  * program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour
1960
1855
  * program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
1961
1856
  *
1962
- * @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag.
1963
- * @return {Command} `this` command for chaining
1857
+ * @param {boolean} [combine=true] - if `true` or omitted, an optional value can be specified directly after the flag.
1964
1858
  */
1965
1859
  combineFlagAndOptionalValue(combine = true) {
1966
1860
  this._combineFlagAndOptionalValue = !!combine;
@@ -1970,8 +1864,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1970
1864
  /**
1971
1865
  * Allow unknown options on the command line.
1972
1866
  *
1973
- * @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options.
1974
- * @return {Command} `this` command for chaining
1867
+ * @param {boolean} [allowUnknown=true] - if `true` or omitted, no error will be thrown
1868
+ * for unknown options.
1975
1869
  */
1976
1870
  allowUnknownOption(allowUnknown = true) {
1977
1871
  this._allowUnknownOption = !!allowUnknown;
@@ -1981,8 +1875,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1981
1875
  /**
1982
1876
  * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
1983
1877
  *
1984
- * @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments.
1985
- * @return {Command} `this` command for chaining
1878
+ * @param {boolean} [allowExcess=true] - if `true` or omitted, no error will be thrown
1879
+ * for excess arguments.
1986
1880
  */
1987
1881
  allowExcessArguments(allowExcess = true) {
1988
1882
  this._allowExcessArguments = !!allowExcess;
@@ -1994,8 +1888,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1994
1888
  * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
1995
1889
  * The default behaviour is non-positional and global options may appear anywhere on the command line.
1996
1890
  *
1997
- * @param {boolean} [positional]
1998
- * @return {Command} `this` command for chaining
1891
+ * @param {boolean} [positional=true]
1999
1892
  */
2000
1893
  enablePositionalOptions(positional = true) {
2001
1894
  this._enablePositionalOptions = !!positional;
@@ -2008,8 +1901,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2008
1901
  * positional options to have been enabled on the program (parent commands).
2009
1902
  * The default behaviour is non-positional and options may appear before or after command-arguments.
2010
1903
  *
2011
- * @param {boolean} [passThrough] for unknown options.
2012
- * @return {Command} `this` command for chaining
1904
+ * @param {boolean} [passThrough=true]
1905
+ * for unknown options.
2013
1906
  */
2014
1907
  passThroughOptions(passThrough = true) {
2015
1908
  this._passThroughOptions = !!passThrough;
@@ -2022,33 +1915,25 @@ Expecting one of '${allowedValues.join("', '")}'`);
2022
1915
  */
2023
1916
 
2024
1917
  _checkForBrokenPassThrough() {
2025
- if (
2026
- this.parent &&
2027
- this._passThroughOptions &&
2028
- !this.parent._enablePositionalOptions
2029
- ) {
2030
- throw new Error(
2031
- `passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`,
2032
- );
1918
+ if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
1919
+ throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
2033
1920
  }
2034
1921
  }
2035
1922
 
2036
1923
  /**
2037
- * Whether to store option values as properties on command object,
2038
- * or store separately (specify false). In both cases the option values can be accessed using .opts().
2039
- *
2040
- * @param {boolean} [storeAsProperties=true]
2041
- * @return {Command} `this` command for chaining
2042
- */
1924
+ * Whether to store option values as properties on command object,
1925
+ * or store separately (specify false). In both cases the option values can be accessed using .opts().
1926
+ *
1927
+ * @param {boolean} [storeAsProperties=true]
1928
+ * @return {Command} `this` command for chaining
1929
+ */
2043
1930
 
2044
1931
  storeOptionsAsProperties(storeAsProperties = true) {
2045
1932
  if (this.options.length) {
2046
1933
  throw new Error('call .storeOptionsAsProperties() before adding options');
2047
1934
  }
2048
1935
  if (Object.keys(this._optionValues).length) {
2049
- throw new Error(
2050
- 'call .storeOptionsAsProperties() before setting option values',
2051
- );
1936
+ throw new Error('call .storeOptionsAsProperties() before setting option values');
2052
1937
  }
2053
1938
  this._storeOptionsAsProperties = !!storeAsProperties;
2054
1939
  return this;
@@ -2058,7 +1943,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2058
1943
  * Retrieve option value.
2059
1944
  *
2060
1945
  * @param {string} key
2061
- * @return {object} value
1946
+ * @return {Object} value
2062
1947
  */
2063
1948
 
2064
1949
  getOptionValue(key) {
@@ -2072,7 +1957,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2072
1957
  * Store option value.
2073
1958
  *
2074
1959
  * @param {string} key
2075
- * @param {object} value
1960
+ * @param {Object} value
2076
1961
  * @return {Command} `this` command for chaining
2077
1962
  */
2078
1963
 
@@ -2081,13 +1966,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
2081
1966
  }
2082
1967
 
2083
1968
  /**
2084
- * Store option value and where the value came from.
2085
- *
2086
- * @param {string} key
2087
- * @param {object} value
2088
- * @param {string} source - expected values are default/config/env/cli/implied
2089
- * @return {Command} `this` command for chaining
2090
- */
1969
+ * Store option value and where the value came from.
1970
+ *
1971
+ * @param {string} key
1972
+ * @param {Object} value
1973
+ * @param {string} source - expected values are default/config/env/cli/implied
1974
+ * @return {Command} `this` command for chaining
1975
+ */
2091
1976
 
2092
1977
  setOptionValueWithSource(key, value, source) {
2093
1978
  if (this._storeOptionsAsProperties) {
@@ -2100,24 +1985,24 @@ Expecting one of '${allowedValues.join("', '")}'`);
2100
1985
  }
2101
1986
 
2102
1987
  /**
2103
- * Get source of option value.
2104
- * Expected values are default | config | env | cli | implied
2105
- *
2106
- * @param {string} key
2107
- * @return {string}
2108
- */
1988
+ * Get source of option value.
1989
+ * Expected values are default | config | env | cli | implied
1990
+ *
1991
+ * @param {string} key
1992
+ * @return {string}
1993
+ */
2109
1994
 
2110
1995
  getOptionValueSource(key) {
2111
1996
  return this._optionValueSources[key];
2112
1997
  }
2113
1998
 
2114
1999
  /**
2115
- * Get source of option value. See also .optsWithGlobals().
2116
- * Expected values are default | config | env | cli | implied
2117
- *
2118
- * @param {string} key
2119
- * @return {string}
2120
- */
2000
+ * Get source of option value. See also .optsWithGlobals().
2001
+ * Expected values are default | config | env | cli | implied
2002
+ *
2003
+ * @param {string} key
2004
+ * @return {string}
2005
+ */
2121
2006
 
2122
2007
  getOptionValueSourceWithGlobals(key) {
2123
2008
  // global overwrites local, like optsWithGlobals
@@ -2143,30 +2028,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
2143
2028
  }
2144
2029
  parseOptions = parseOptions || {};
2145
2030
 
2146
- // auto-detect argument conventions if nothing supplied
2147
- if (argv === undefined && parseOptions.from === undefined) {
2148
- if (process$1.versions?.electron) {
2149
- parseOptions.from = 'electron';
2150
- }
2151
- // check node specific options for scenarios where user CLI args follow executable without scriptname
2152
- const execArgv = process$1.execArgv ?? [];
2153
- if (
2154
- execArgv.includes('-e') ||
2155
- execArgv.includes('--eval') ||
2156
- execArgv.includes('-p') ||
2157
- execArgv.includes('--print')
2158
- ) {
2159
- parseOptions.from = 'eval'; // internal usage, not documented
2160
- }
2161
- }
2162
-
2163
- // default to using process.argv
2031
+ // Default to using process.argv
2164
2032
  if (argv === undefined) {
2165
2033
  argv = process$1.argv;
2034
+ // @ts-ignore: unknown property
2035
+ if (process$1.versions && process$1.versions.electron) {
2036
+ parseOptions.from = 'electron';
2037
+ }
2166
2038
  }
2167
2039
  this.rawArgs = argv.slice();
2168
2040
 
2169
- // extract the user args and scriptPath
2041
+ // make it a little easier for callers by supporting various argv conventions
2170
2042
  let userArgs;
2171
2043
  switch (parseOptions.from) {
2172
2044
  case undefined:
@@ -2175,7 +2047,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2175
2047
  userArgs = argv.slice(2);
2176
2048
  break;
2177
2049
  case 'electron':
2178
- // @ts-ignore: because defaultApp is an unknown property
2050
+ // @ts-ignore: unknown property
2179
2051
  if (process$1.defaultApp) {
2180
2052
  this._scriptPath = argv[1];
2181
2053
  userArgs = argv.slice(2);
@@ -2186,18 +2058,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
2186
2058
  case 'user':
2187
2059
  userArgs = argv.slice(0);
2188
2060
  break;
2189
- case 'eval':
2190
- userArgs = argv.slice(1);
2191
- break;
2192
2061
  default:
2193
- throw new Error(
2194
- `unexpected parse option { from: '${parseOptions.from}' }`,
2195
- );
2062
+ throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
2196
2063
  }
2197
2064
 
2198
2065
  // Find default name for program from arguments.
2199
- if (!this._name && this._scriptPath)
2200
- this.nameFromFilename(this._scriptPath);
2066
+ if (!this._name && this._scriptPath) this.nameFromFilename(this._scriptPath);
2201
2067
  this._name = this._name || 'program';
2202
2068
 
2203
2069
  return userArgs;
@@ -2206,22 +2072,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
2206
2072
  /**
2207
2073
  * Parse `argv`, setting options and invoking commands when defined.
2208
2074
  *
2209
- * Use parseAsync instead of parse if any of your action handlers are async.
2210
- *
2211
- * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
2212
- *
2213
- * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
2214
- * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
2215
- * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
2216
- * - `'user'`: just user arguments
2075
+ * The default expectation is that the arguments are from node and have the application as argv[0]
2076
+ * and the script being run in argv[1], with user parameters after that.
2217
2077
  *
2218
2078
  * @example
2219
- * program.parse(); // parse process.argv and auto-detect electron and special node flags
2220
- * program.parse(process.argv); // assume argv[0] is app and argv[1] is script
2079
+ * program.parse(process.argv);
2080
+ * program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
2221
2081
  * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
2222
2082
  *
2223
2083
  * @param {string[]} [argv] - optional, defaults to process.argv
2224
- * @param {object} [parseOptions] - optionally specify style of options with from: node/user/electron
2084
+ * @param {Object} [parseOptions] - optionally specify style of options with from: node/user/electron
2225
2085
  * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
2226
2086
  * @return {Command} `this` command for chaining
2227
2087
  */
@@ -2236,20 +2096,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
2236
2096
  /**
2237
2097
  * Parse `argv`, setting options and invoking commands when defined.
2238
2098
  *
2239
- * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
2099
+ * Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
2240
2100
  *
2241
- * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
2242
- * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
2243
- * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
2244
- * - `'user'`: just user arguments
2101
+ * The default expectation is that the arguments are from node and have the application as argv[0]
2102
+ * and the script being run in argv[1], with user parameters after that.
2245
2103
  *
2246
2104
  * @example
2247
- * await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
2248
- * await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
2105
+ * await program.parseAsync(process.argv);
2106
+ * await program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
2249
2107
  * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
2250
2108
  *
2251
2109
  * @param {string[]} [argv]
2252
- * @param {object} [parseOptions]
2110
+ * @param {Object} [parseOptions]
2253
2111
  * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
2254
2112
  * @return {Promise}
2255
2113
  */
@@ -2281,9 +2139,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2281
2139
  if (sourceExt.includes(path.extname(baseName))) return undefined;
2282
2140
 
2283
2141
  // Try all the extensions.
2284
- const foundExt = sourceExt.find((ext) =>
2285
- fs.existsSync(`${localBin}${ext}`),
2286
- );
2142
+ const foundExt = sourceExt.find(ext => fs.existsSync(`${localBin}${ext}`));
2287
2143
  if (foundExt) return `${localBin}${foundExt}`;
2288
2144
 
2289
2145
  return undefined;
@@ -2294,8 +2150,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2294
2150
  this._checkForConflictingOptions();
2295
2151
 
2296
2152
  // executableFile and executableDir might be full path, or just a name
2297
- let executableFile =
2298
- subcommand._executableFile || `${this._name}-${subcommand._name}`;
2153
+ let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
2299
2154
  let executableDir = this._executableDir || '';
2300
2155
  if (this._scriptPath) {
2301
2156
  let resolvedScriptPath; // resolve possible symlink for installed npm binary
@@ -2304,10 +2159,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2304
2159
  } catch (err) {
2305
2160
  resolvedScriptPath = this._scriptPath;
2306
2161
  }
2307
- executableDir = path.resolve(
2308
- path.dirname(resolvedScriptPath),
2309
- executableDir,
2310
- );
2162
+ executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
2311
2163
  }
2312
2164
 
2313
2165
  // Look for a local file in preference to a command in PATH.
@@ -2316,15 +2168,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2316
2168
 
2317
2169
  // Legacy search using prefix of script name instead of command name
2318
2170
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
2319
- const legacyName = path.basename(
2320
- this._scriptPath,
2321
- path.extname(this._scriptPath),
2322
- );
2171
+ const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
2323
2172
  if (legacyName !== this._name) {
2324
- localFile = findFile(
2325
- executableDir,
2326
- `${legacyName}-${subcommand._name}`,
2327
- );
2173
+ localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
2328
2174
  }
2329
2175
  }
2330
2176
  executableFile = localFile || executableFile;
@@ -2350,13 +2196,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
2350
2196
  proc = childProcess.spawn(process$1.execPath, args, { stdio: 'inherit' });
2351
2197
  }
2352
2198
 
2353
- if (!proc.killed) {
2354
- // testing mainly to avoid leak warnings during unit tests with mocked spawn
2199
+ if (!proc.killed) { // testing mainly to avoid leak warnings during unit tests with mocked spawn
2355
2200
  const signals = ['SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGINT', 'SIGHUP'];
2356
2201
  signals.forEach((signal) => {
2202
+ // @ts-ignore
2357
2203
  process$1.on(signal, () => {
2358
2204
  if (proc.killed === false && proc.exitCode === null) {
2359
- // @ts-ignore because signals not typed to known strings
2360
2205
  proc.kill(signal);
2361
2206
  }
2362
2207
  });
@@ -2365,22 +2210,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
2365
2210
 
2366
2211
  // By default terminate process when spawned process terminates.
2367
2212
  const exitCallback = this._exitCallback;
2368
- proc.on('close', (code) => {
2213
+ proc.on('close', (code, _signal) => {
2369
2214
  code = code ?? 1; // code is null if spawned process terminated due to a signal
2370
2215
  if (!exitCallback) {
2371
2216
  process$1.exit(code);
2372
2217
  } else {
2373
- exitCallback(
2374
- new CommanderError$2(
2375
- code,
2376
- 'commander.executeSubCommandAsync',
2377
- '(close)',
2378
- ),
2379
- );
2218
+ exitCallback(new CommanderError$2(code, 'commander.executeSubCommandAsync', '(close)'));
2380
2219
  }
2381
2220
  });
2382
2221
  proc.on('error', (err) => {
2383
- // @ts-ignore: because err.code is an unknown property
2222
+ // @ts-ignore
2384
2223
  if (err.code === 'ENOENT') {
2385
2224
  const executableDirMessage = executableDir
2386
2225
  ? `searched for local subcommand relative to directory '${executableDir}'`
@@ -2390,18 +2229,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
2390
2229
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
2391
2230
  - ${executableDirMessage}`;
2392
2231
  throw new Error(executableMissing);
2393
- // @ts-ignore: because err.code is an unknown property
2232
+ // @ts-ignore
2394
2233
  } else if (err.code === 'EACCES') {
2395
2234
  throw new Error(`'${executableFile}' not executable`);
2396
2235
  }
2397
2236
  if (!exitCallback) {
2398
2237
  process$1.exit(1);
2399
2238
  } else {
2400
- const wrappedError = new CommanderError$2(
2401
- 1,
2402
- 'commander.executeSubCommandAsync',
2403
- '(error)',
2404
- );
2239
+ const wrappedError = new CommanderError$2(1, 'commander.executeSubCommandAsync', '(error)');
2405
2240
  wrappedError.nestedError = err;
2406
2241
  exitCallback(wrappedError);
2407
2242
  }
@@ -2420,11 +2255,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2420
2255
  if (!subCommand) this.help({ error: true });
2421
2256
 
2422
2257
  let promiseChain;
2423
- promiseChain = this._chainOrCallSubCommandHook(
2424
- promiseChain,
2425
- subCommand,
2426
- 'preSubcommand',
2427
- );
2258
+ promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, 'preSubcommand');
2428
2259
  promiseChain = this._chainOrCall(promiseChain, () => {
2429
2260
  if (subCommand._executableHandler) {
2430
2261
  this._executeSubCommand(subCommand, operands.concat(unknown));
@@ -2452,11 +2283,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2452
2283
  }
2453
2284
 
2454
2285
  // Fallback to parsing the help flag to invoke the help.
2455
- return this._dispatchSubcommand(
2456
- subcommandName,
2457
- [],
2458
- [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? '--help'],
2459
- );
2286
+ return this._dispatchSubcommand(subcommandName, [], [
2287
+ this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? '--help'
2288
+ ]);
2460
2289
  }
2461
2290
 
2462
2291
  /**
@@ -2473,10 +2302,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2473
2302
  }
2474
2303
  });
2475
2304
  // too many
2476
- if (
2477
- this.registeredArguments.length > 0 &&
2478
- this.registeredArguments[this.registeredArguments.length - 1].variadic
2479
- ) {
2305
+ if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) {
2480
2306
  return;
2481
2307
  }
2482
2308
  if (this.args.length > this.registeredArguments.length) {
@@ -2496,12 +2322,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2496
2322
  let parsedValue = value;
2497
2323
  if (value !== null && argument.parseArg) {
2498
2324
  const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
2499
- parsedValue = this._callParseArg(
2500
- argument,
2501
- value,
2502
- previous,
2503
- invalidValueMessage,
2504
- );
2325
+ parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage);
2505
2326
  }
2506
2327
  return parsedValue;
2507
2328
  };
@@ -2566,8 +2387,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2566
2387
  const hooks = [];
2567
2388
  this._getCommandAndAncestors()
2568
2389
  .reverse()
2569
- .filter((cmd) => cmd._lifeCycleHooks[event] !== undefined)
2570
- .forEach((hookedCommand) => {
2390
+ .filter(cmd => cmd._lifeCycleHooks[event] !== undefined)
2391
+ .forEach(hookedCommand => {
2571
2392
  hookedCommand._lifeCycleHooks[event].forEach((callback) => {
2572
2393
  hooks.push({ hookedCommand, callback });
2573
2394
  });
@@ -2623,26 +2444,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
2623
2444
  if (operands && this._findCommand(operands[0])) {
2624
2445
  return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
2625
2446
  }
2626
- if (
2627
- this._getHelpCommand() &&
2628
- operands[0] === this._getHelpCommand().name()
2629
- ) {
2447
+ if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
2630
2448
  return this._dispatchHelpCommand(operands[1]);
2631
2449
  }
2632
2450
  if (this._defaultCommandName) {
2633
2451
  this._outputHelpIfRequested(unknown); // Run the help for default command from parent rather than passing to default command
2634
- return this._dispatchSubcommand(
2635
- this._defaultCommandName,
2636
- operands,
2637
- unknown,
2638
- );
2452
+ return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
2639
2453
  }
2640
- if (
2641
- this.commands.length &&
2642
- this.args.length === 0 &&
2643
- !this._actionHandler &&
2644
- !this._defaultCommandName
2645
- ) {
2454
+ if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
2646
2455
  // probably missing subcommand and no handler, user needs help (and exit)
2647
2456
  this.help({ error: true });
2648
2457
  }
@@ -2665,9 +2474,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2665
2474
 
2666
2475
  let promiseChain;
2667
2476
  promiseChain = this._chainOrCallHooks(promiseChain, 'preAction');
2668
- promiseChain = this._chainOrCall(promiseChain, () =>
2669
- this._actionHandler(this.processedArgs),
2670
- );
2477
+ promiseChain = this._chainOrCall(promiseChain, () => this._actionHandler(this.processedArgs));
2671
2478
  if (this.parent) {
2672
2479
  promiseChain = this._chainOrCall(promiseChain, () => {
2673
2480
  this.parent.emit(commandEvent, operands, unknown); // legacy
@@ -2681,8 +2488,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2681
2488
  this._processArguments();
2682
2489
  this.parent.emit(commandEvent, operands, unknown); // legacy
2683
2490
  } else if (operands.length) {
2684
- if (this._findCommand('*')) {
2685
- // legacy default command
2491
+ if (this._findCommand('*')) { // legacy default command
2686
2492
  return this._dispatchSubcommand('*', operands, unknown);
2687
2493
  }
2688
2494
  if (this.listenerCount('command:*')) {
@@ -2709,13 +2515,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2709
2515
  * Find matching command.
2710
2516
  *
2711
2517
  * @private
2712
- * @return {Command | undefined}
2713
2518
  */
2714
2519
  _findCommand(name) {
2715
2520
  if (!name) return undefined;
2716
- return this.commands.find(
2717
- (cmd) => cmd._name === name || cmd._aliases.includes(name),
2718
- );
2521
+ return this.commands.find(cmd => cmd._name === name || cmd._aliases.includes(name));
2719
2522
  }
2720
2523
 
2721
2524
  /**
@@ -2723,11 +2526,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2723
2526
  *
2724
2527
  * @param {string} arg
2725
2528
  * @return {Option}
2726
- * @package
2529
+ * @package internal use only
2727
2530
  */
2728
2531
 
2729
2532
  _findOption(arg) {
2730
- return this.options.find((option) => option.is(arg));
2533
+ return this.options.find(option => option.is(arg));
2731
2534
  }
2732
2535
 
2733
2536
  /**
@@ -2741,10 +2544,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2741
2544
  // Walk up hierarchy so can call in subcommand after checking for displaying help.
2742
2545
  this._getCommandAndAncestors().forEach((cmd) => {
2743
2546
  cmd.options.forEach((anOption) => {
2744
- if (
2745
- anOption.mandatory &&
2746
- cmd.getOptionValue(anOption.attributeName()) === undefined
2747
- ) {
2547
+ if (anOption.mandatory && (cmd.getOptionValue(anOption.attributeName()) === undefined)) {
2748
2548
  cmd.missingMandatoryOptionValue(anOption);
2749
2549
  }
2750
2550
  });
@@ -2757,21 +2557,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
2757
2557
  * @private
2758
2558
  */
2759
2559
  _checkForConflictingLocalOptions() {
2760
- const definedNonDefaultOptions = this.options.filter((option) => {
2761
- const optionKey = option.attributeName();
2762
- if (this.getOptionValue(optionKey) === undefined) {
2763
- return false;
2560
+ const definedNonDefaultOptions = this.options.filter(
2561
+ (option) => {
2562
+ const optionKey = option.attributeName();
2563
+ if (this.getOptionValue(optionKey) === undefined) {
2564
+ return false;
2565
+ }
2566
+ return this.getOptionValueSource(optionKey) !== 'default';
2764
2567
  }
2765
- return this.getOptionValueSource(optionKey) !== 'default';
2766
- });
2568
+ );
2767
2569
 
2768
2570
  const optionsWithConflicting = definedNonDefaultOptions.filter(
2769
- (option) => option.conflictsWith.length > 0,
2571
+ (option) => option.conflictsWith.length > 0
2770
2572
  );
2771
2573
 
2772
2574
  optionsWithConflicting.forEach((option) => {
2773
2575
  const conflictingAndDefined = definedNonDefaultOptions.find((defined) =>
2774
- option.conflictsWith.includes(defined.attributeName()),
2576
+ option.conflictsWith.includes(defined.attributeName())
2775
2577
  );
2776
2578
  if (conflictingAndDefined) {
2777
2579
  this._conflictingOption(option, conflictingAndDefined);
@@ -2851,8 +2653,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2851
2653
  value = args.shift();
2852
2654
  }
2853
2655
  this.emit(`option:${option.name()}`, value);
2854
- } else {
2855
- // boolean flag
2656
+ } else { // boolean flag
2856
2657
  this.emit(`option:${option.name()}`);
2857
2658
  }
2858
2659
  activeVariadicOption = option.variadic ? option : null;
@@ -2864,10 +2665,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2864
2665
  if (arg.length > 2 && arg[0] === '-' && arg[1] !== '-') {
2865
2666
  const option = this._findOption(`-${arg[1]}`);
2866
2667
  if (option) {
2867
- if (
2868
- option.required ||
2869
- (option.optional && this._combineFlagAndOptionalValue)
2870
- ) {
2668
+ if (option.required || (option.optional && this._combineFlagAndOptionalValue)) {
2871
2669
  // option with value following in same argument
2872
2670
  this.emit(`option:${option.name()}`, arg.slice(2));
2873
2671
  } else {
@@ -2898,19 +2696,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
2898
2696
  }
2899
2697
 
2900
2698
  // If using positionalOptions, stop processing our options at subcommand.
2901
- if (
2902
- (this._enablePositionalOptions || this._passThroughOptions) &&
2903
- operands.length === 0 &&
2904
- unknown.length === 0
2905
- ) {
2699
+ if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
2906
2700
  if (this._findCommand(arg)) {
2907
2701
  operands.push(arg);
2908
2702
  if (args.length > 0) unknown.push(...args);
2909
2703
  break;
2910
- } else if (
2911
- this._getHelpCommand() &&
2912
- arg === this._getHelpCommand().name()
2913
- ) {
2704
+ } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
2914
2705
  operands.push(arg);
2915
2706
  if (args.length > 0) operands.push(...args);
2916
2707
  break;
@@ -2938,7 +2729,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2938
2729
  /**
2939
2730
  * Return an object containing local option values as key-value pairs.
2940
2731
  *
2941
- * @return {object}
2732
+ * @return {Object}
2942
2733
  */
2943
2734
  opts() {
2944
2735
  if (this._storeOptionsAsProperties) {
@@ -2948,8 +2739,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2948
2739
 
2949
2740
  for (let i = 0; i < len; i++) {
2950
2741
  const key = this.options[i].attributeName();
2951
- result[key] =
2952
- key === this._versionOptionName ? this._version : this[key];
2742
+ result[key] = key === this._versionOptionName ? this._version : this[key];
2953
2743
  }
2954
2744
  return result;
2955
2745
  }
@@ -2960,13 +2750,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
2960
2750
  /**
2961
2751
  * Return an object containing merged local and global option values as key-value pairs.
2962
2752
  *
2963
- * @return {object}
2753
+ * @return {Object}
2964
2754
  */
2965
2755
  optsWithGlobals() {
2966
2756
  // globals overwrite locals
2967
2757
  return this._getCommandAndAncestors().reduce(
2968
2758
  (combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()),
2969
- {},
2759
+ {}
2970
2760
  );
2971
2761
  }
2972
2762
 
@@ -2974,16 +2764,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
2974
2764
  * Display error message and exit (or call exitOverride).
2975
2765
  *
2976
2766
  * @param {string} message
2977
- * @param {object} [errorOptions]
2767
+ * @param {Object} [errorOptions]
2978
2768
  * @param {string} [errorOptions.code] - an id string representing the error
2979
2769
  * @param {number} [errorOptions.exitCode] - used with process.exit
2980
2770
  */
2981
2771
  error(message, errorOptions) {
2982
2772
  // output handling
2983
- this._outputConfiguration.outputError(
2984
- `${message}\n`,
2985
- this._outputConfiguration.writeErr,
2986
- );
2773
+ this._outputConfiguration.outputError(`${message}\n`, this._outputConfiguration.writeErr);
2987
2774
  if (typeof this._showHelpAfterError === 'string') {
2988
2775
  this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`);
2989
2776
  } else if (this._showHelpAfterError) {
@@ -3009,18 +2796,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
3009
2796
  if (option.envVar && option.envVar in process$1.env) {
3010
2797
  const optionKey = option.attributeName();
3011
2798
  // Priority check. Do not overwrite cli or options from unknown source (client-code).
3012
- if (
3013
- this.getOptionValue(optionKey) === undefined ||
3014
- ['default', 'config', 'env'].includes(
3015
- this.getOptionValueSource(optionKey),
3016
- )
3017
- ) {
3018
- if (option.required || option.optional) {
3019
- // option can take a value
2799
+ if (this.getOptionValue(optionKey) === undefined || ['default', 'config', 'env'].includes(this.getOptionValueSource(optionKey))) {
2800
+ if (option.required || option.optional) { // option can take a value
3020
2801
  // keep very simple, optional always takes value
3021
2802
  this.emit(`optionEnv:${option.name()}`, process$1.env[option.envVar]);
3022
- } else {
3023
- // boolean
2803
+ } else { // boolean
3024
2804
  // keep very simple, only care that envVar defined and not the value
3025
2805
  this.emit(`optionEnv:${option.name()}`);
3026
2806
  }
@@ -3037,30 +2817,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
3037
2817
  _parseOptionsImplied() {
3038
2818
  const dualHelper = new DualOptions(this.options);
3039
2819
  const hasCustomOptionValue = (optionKey) => {
3040
- return (
3041
- this.getOptionValue(optionKey) !== undefined &&
3042
- !['default', 'implied'].includes(this.getOptionValueSource(optionKey))
3043
- );
2820
+ return this.getOptionValue(optionKey) !== undefined && !['default', 'implied'].includes(this.getOptionValueSource(optionKey));
3044
2821
  };
3045
2822
  this.options
3046
- .filter(
3047
- (option) =>
3048
- option.implied !== undefined &&
3049
- hasCustomOptionValue(option.attributeName()) &&
3050
- dualHelper.valueFromOption(
3051
- this.getOptionValue(option.attributeName()),
3052
- option,
3053
- ),
3054
- )
2823
+ .filter(option => (option.implied !== undefined) &&
2824
+ hasCustomOptionValue(option.attributeName()) &&
2825
+ dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option))
3055
2826
  .forEach((option) => {
3056
2827
  Object.keys(option.implied)
3057
- .filter((impliedKey) => !hasCustomOptionValue(impliedKey))
3058
- .forEach((impliedKey) => {
3059
- this.setOptionValueWithSource(
3060
- impliedKey,
3061
- option.implied[impliedKey],
3062
- 'implied',
3063
- );
2828
+ .filter(impliedKey => !hasCustomOptionValue(impliedKey))
2829
+ .forEach(impliedKey => {
2830
+ this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], 'implied');
3064
2831
  });
3065
2832
  });
3066
2833
  }
@@ -3114,18 +2881,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
3114
2881
  const findBestOptionFromValue = (option) => {
3115
2882
  const optionKey = option.attributeName();
3116
2883
  const optionValue = this.getOptionValue(optionKey);
3117
- const negativeOption = this.options.find(
3118
- (target) => target.negate && optionKey === target.attributeName(),
3119
- );
3120
- const positiveOption = this.options.find(
3121
- (target) => !target.negate && optionKey === target.attributeName(),
3122
- );
3123
- if (
3124
- negativeOption &&
3125
- ((negativeOption.presetArg === undefined && optionValue === false) ||
3126
- (negativeOption.presetArg !== undefined &&
3127
- optionValue === negativeOption.presetArg))
3128
- ) {
2884
+ const negativeOption = this.options.find(target => target.negate && optionKey === target.attributeName());
2885
+ const positiveOption = this.options.find(target => !target.negate && optionKey === target.attributeName());
2886
+ if (negativeOption && (
2887
+ (negativeOption.presetArg === undefined && optionValue === false) ||
2888
+ (negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)
2889
+ )) {
3129
2890
  return negativeOption;
3130
2891
  }
3131
2892
  return positiveOption || option;
@@ -3159,14 +2920,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
3159
2920
  if (flag.startsWith('--') && this._showSuggestionAfterError) {
3160
2921
  // Looping to pick up the global options too
3161
2922
  let candidateFlags = [];
3162
- // eslint-disable-next-line @typescript-eslint/no-this-alias
3163
2923
  let command = this;
3164
2924
  do {
3165
- const moreFlags = command
3166
- .createHelp()
3167
- .visibleOptions(command)
3168
- .filter((option) => option.long)
3169
- .map((option) => option.long);
2925
+ const moreFlags = command.createHelp().visibleOptions(command)
2926
+ .filter(option => option.long)
2927
+ .map(option => option.long);
3170
2928
  candidateFlags = candidateFlags.concat(moreFlags);
3171
2929
  command = command.parent;
3172
2930
  } while (command && !command._enablePositionalOptions);
@@ -3188,7 +2946,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3188
2946
  if (this._allowExcessArguments) return;
3189
2947
 
3190
2948
  const expected = this.registeredArguments.length;
3191
- const s = expected === 1 ? '' : 's';
2949
+ const s = (expected === 1) ? '' : 's';
3192
2950
  const forSubcommand = this.parent ? ` for '${this.name()}'` : '';
3193
2951
  const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
3194
2952
  this.error(message, { code: 'commander.excessArguments' });
@@ -3206,13 +2964,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
3206
2964
 
3207
2965
  if (this._showSuggestionAfterError) {
3208
2966
  const candidateNames = [];
3209
- this.createHelp()
3210
- .visibleCommands(this)
3211
- .forEach((command) => {
3212
- candidateNames.push(command.name());
3213
- // just visible alias
3214
- if (command.alias()) candidateNames.push(command.alias());
3215
- });
2967
+ this.createHelp().visibleCommands(this).forEach((command) => {
2968
+ candidateNames.push(command.name());
2969
+ // just visible alias
2970
+ if (command.alias()) candidateNames.push(command.alias());
2971
+ });
3216
2972
  suggestion = suggestSimilar(unknownName, candidateNames);
3217
2973
  }
3218
2974
 
@@ -3253,12 +3009,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
3253
3009
  * Set the description.
3254
3010
  *
3255
3011
  * @param {string} [str]
3256
- * @param {object} [argsDescription]
3012
+ * @param {Object} [argsDescription]
3257
3013
  * @return {(string|Command)}
3258
3014
  */
3259
3015
  description(str, argsDescription) {
3260
- if (str === undefined && argsDescription === undefined)
3261
- return this._description;
3016
+ if (str === undefined && argsDescription === undefined) return this._description;
3262
3017
  this._description = str;
3263
3018
  if (argsDescription) {
3264
3019
  this._argsDescription = argsDescription;
@@ -3291,27 +3046,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
3291
3046
  if (alias === undefined) return this._aliases[0]; // just return first, for backwards compatibility
3292
3047
 
3293
3048
  /** @type {Command} */
3294
- // eslint-disable-next-line @typescript-eslint/no-this-alias
3295
3049
  let command = this;
3296
- if (
3297
- this.commands.length !== 0 &&
3298
- this.commands[this.commands.length - 1]._executableHandler
3299
- ) {
3050
+ if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
3300
3051
  // assume adding alias for last added executable subcommand, rather than this
3301
3052
  command = this.commands[this.commands.length - 1];
3302
3053
  }
3303
3054
 
3304
- if (alias === command._name)
3305
- throw new Error("Command alias can't be the same as its name");
3055
+ if (alias === command._name) throw new Error('Command alias can\'t be the same as its name');
3306
3056
  const matchingCommand = this.parent?._findCommand(alias);
3307
3057
  if (matchingCommand) {
3308
3058
  // c.f. _registerCommand
3309
- const existingCmd = [matchingCommand.name()]
3310
- .concat(matchingCommand.aliases())
3311
- .join('|');
3312
- throw new Error(
3313
- `cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`,
3314
- );
3059
+ const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join('|');
3060
+ throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
3315
3061
  }
3316
3062
 
3317
3063
  command._aliases.push(alias);
@@ -3349,13 +3095,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
3349
3095
  const args = this.registeredArguments.map((arg) => {
3350
3096
  return humanReadableArgName(arg);
3351
3097
  });
3352
- return []
3353
- .concat(
3354
- this.options.length || this._helpOption !== null ? '[options]' : [],
3355
- this.commands.length ? '[command]' : [],
3356
- this.registeredArguments.length ? args : [],
3357
- )
3358
- .join(' ');
3098
+ return [].concat(
3099
+ (this.options.length || (this._helpOption !== null) ? '[options]' : []),
3100
+ (this.commands.length ? '[command]' : []),
3101
+ (this.registeredArguments.length ? args : [])
3102
+ ).join(' ');
3359
3103
  }
3360
3104
 
3361
3105
  this._usage = str;
@@ -3422,10 +3166,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3422
3166
  helpInformation(contextOptions) {
3423
3167
  const helper = this.createHelp();
3424
3168
  if (helper.helpWidth === undefined) {
3425
- helper.helpWidth =
3426
- contextOptions && contextOptions.error
3427
- ? this._outputConfiguration.getErrHelpWidth()
3428
- : this._outputConfiguration.getOutHelpWidth();
3169
+ helper.helpWidth = (contextOptions && contextOptions.error) ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
3429
3170
  }
3430
3171
  return helper.formatHelp(this, helper);
3431
3172
  }
@@ -3464,18 +3205,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
3464
3205
  }
3465
3206
  const context = this._getHelpContext(contextOptions);
3466
3207
 
3467
- this._getCommandAndAncestors()
3468
- .reverse()
3469
- .forEach((command) => command.emit('beforeAllHelp', context));
3208
+ this._getCommandAndAncestors().reverse().forEach(command => command.emit('beforeAllHelp', context));
3470
3209
  this.emit('beforeHelp', context);
3471
3210
 
3472
3211
  let helpInformation = this.helpInformation(context);
3473
3212
  if (deprecatedCallback) {
3474
3213
  helpInformation = deprecatedCallback(helpInformation);
3475
- if (
3476
- typeof helpInformation !== 'string' &&
3477
- !Buffer.isBuffer(helpInformation)
3478
- ) {
3214
+ if (typeof helpInformation !== 'string' && !Buffer.isBuffer(helpInformation)) {
3479
3215
  throw new Error('outputHelp callback must return a string or a Buffer');
3480
3216
  }
3481
3217
  }
@@ -3485,9 +3221,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3485
3221
  this.emit(this._getHelpOption().long); // deprecated
3486
3222
  }
3487
3223
  this.emit('afterHelp', context);
3488
- this._getCommandAndAncestors().forEach((command) =>
3489
- command.emit('afterAllHelp', context),
3490
- );
3224
+ this._getCommandAndAncestors().forEach(command => command.emit('afterAllHelp', context));
3491
3225
  }
3492
3226
 
3493
3227
  /**
@@ -3527,7 +3261,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3527
3261
  * Returns null if has been disabled with .helpOption(false).
3528
3262
  *
3529
3263
  * @returns {(Option | null)} the help option
3530
- * @package
3264
+ * @package internal use only
3531
3265
  */
3532
3266
  _getHelpOption() {
3533
3267
  // Lazy create help option on demand.
@@ -3560,12 +3294,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3560
3294
  help(contextOptions) {
3561
3295
  this.outputHelp(contextOptions);
3562
3296
  let exitCode = process$1.exitCode || 0;
3563
- if (
3564
- exitCode === 0 &&
3565
- contextOptions &&
3566
- typeof contextOptions !== 'function' &&
3567
- contextOptions.error
3568
- ) {
3297
+ if (exitCode === 0 && contextOptions && typeof contextOptions !== 'function' && contextOptions.error) {
3569
3298
  exitCode = 1;
3570
3299
  }
3571
3300
  // message: do not have all displayed text available so only passing placeholder.
@@ -3613,7 +3342,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3613
3342
 
3614
3343
  _outputHelpIfRequested(args) {
3615
3344
  const helpOption = this._getHelpOption();
3616
- const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
3345
+ const helpRequested = helpOption && args.find(arg => helpOption.is(arg));
3617
3346
  if (helpRequested) {
3618
3347
  this.outputHelp();
3619
3348
  // (Do not have all displayed text available so only passing placeholder.)
@@ -3646,9 +3375,7 @@ function incrementNodeInspectorPort(args) {
3646
3375
  if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
3647
3376
  // e.g. --inspect
3648
3377
  debugOption = match[1];
3649
- } else if (
3650
- (match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null
3651
- ) {
3378
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
3652
3379
  debugOption = match[1];
3653
3380
  if (/^\d+$/.test(match[3])) {
3654
3381
  // e.g. --inspect=1234
@@ -3657,9 +3384,7 @@ function incrementNodeInspectorPort(args) {
3657
3384
  // e.g. --inspect=localhost
3658
3385
  debugHost = match[3];
3659
3386
  }
3660
- } else if (
3661
- (match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null
3662
- ) {
3387
+ } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
3663
3388
  // e.g. --inspect=localhost:1234
3664
3389
  debugOption = match[1];
3665
3390
  debugHost = match[3];
@@ -3712,10 +3437,10 @@ const {
3712
3437
  Command,
3713
3438
  Argument,
3714
3439
  Option,
3715
- Help,
3440
+ Help
3716
3441
  } = commander;
3717
3442
 
3718
- var version = "1.6.0";
3443
+ var version = "1.6.1";
3719
3444
 
3720
3445
  const program = new Command();
3721
3446
  program.name("biliLive").description("biliLive-tools命令行").version(version);
@@ -3735,8 +3460,8 @@ program
3735
3460
  throw new Error(`${c.configFolder}参数不存在,请先重新运行 config gen 命令`);
3736
3461
  }
3737
3462
  // 下面两行顺序不能换(
3738
- const { init } = await Promise.resolve().then(function () { return require('./index--sFOOs5S.js'); }).then(function (n) { return n.index; });
3739
- const { serverStart } = await Promise.resolve().then(function () { return require('./index-El6sDas6.js'); });
3463
+ const { init } = await Promise.resolve().then(function () { return require('./index-C8BJBjBO.js'); }).then(function (n) { return n.index; });
3464
+ const { serverStart } = await Promise.resolve().then(function () { return require('./index-0wA94Agk.js'); });
3740
3465
  const globalConfig = {
3741
3466
  ffmpegPresetPath: path$1.join(c.configFolder, "ffmpeg_presets.json"),
3742
3467
  videoPresetPath: path$1.join(c.configFolder, "presets.json"),