@bemoje/cli 2.1.4 → 2.1.6

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.
Files changed (3) hide show
  1. package/index.d.ts +578 -794
  2. package/index.mjs +563 -692
  3. package/package.json +4 -2
package/index.mjs CHANGED
@@ -1,39 +1,34 @@
1
1
  import C from 'ansi-colors';
2
- import humanizeDuration from 'humanize-duration';
3
- import { inspect } from 'util';
4
- import { isFunction } from 'es-toolkit/predicate';
5
- import { isPrimitive } from 'es-toolkit/predicate';
6
- import { isPromise } from 'util/types';
7
- import { isString } from 'es-toolkit/predicate';
8
- import { kebabCase } from 'es-toolkit/string';
2
+ import { isFunction, isString, isPrimitive } from 'es-toolkit/predicate';
9
3
  import memoizee from 'memoizee';
10
4
  import { ms } from 'enhanced-ms';
11
- import { parseArgs } from 'util';
5
+ import { inspect, parseArgs } from 'util';
6
+ import { kebabCase } from 'es-toolkit/string';
7
+ import humanizeDuration from 'humanize-duration';
8
+ import { isPromise } from 'util/types';
12
9
 
13
10
  var __defProp = Object.defineProperty;
14
- var __name = (target, value) => {
15
- return __defProp(target, 'name', { value, configurable: true });
16
- };
11
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
12
 
18
13
  // ../decorators/src/assertDescriptorValueIsFunction.ts
19
14
  function assertDescriptorValueIsFunction(key, descriptor) {
20
- if (!(typeof descriptor.value === 'function' && descriptor.value !== Function.prototype)) {
15
+ if (!(typeof descriptor.value === "function" && descriptor.value !== Function.prototype)) {
21
16
  throw new TypeError(`"value" not a function for ${key} with descriptor: ${JSON.stringify(descriptor)}.`);
22
17
  }
23
18
  }
24
- __name(assertDescriptorValueIsFunction, 'assertDescriptorValueIsFunction');
19
+ __name(assertDescriptorValueIsFunction, "assertDescriptorValueIsFunction");
25
20
 
26
21
  // ../object/src/entriesOf.ts
27
22
  function entriesOf(obj) {
28
23
  return Object.entries(obj);
29
24
  }
30
- __name(entriesOf, 'entriesOf');
25
+ __name(entriesOf, "entriesOf");
31
26
 
32
27
  // ../object/src/keysOf.ts
33
28
  function keysOf(obj) {
34
29
  return Object.keys(obj);
35
30
  }
36
- __name(keysOf, 'keysOf');
31
+ __name(keysOf, "keysOf");
37
32
 
38
33
  // ../object/src/filterObject.ts
39
34
  function filterObject(obj, predicate) {
@@ -45,7 +40,7 @@ function filterObject(obj, predicate) {
45
40
  }
46
41
  return accum;
47
42
  }
48
- __name(filterObject, 'filterObject');
43
+ __name(filterObject, "filterObject");
49
44
 
50
45
  // ../object/src/objSortKeys.ts
51
46
  function objSortKeys(o, compare) {
@@ -59,13 +54,13 @@ function objSortKeys(o, compare) {
59
54
  }
60
55
  return Object.fromEntries(entries);
61
56
  }
62
- __name(objSortKeys, 'objSortKeys');
57
+ __name(objSortKeys, "objSortKeys");
63
58
 
64
59
  // ../object/src/valuesOf.ts
65
60
  function valuesOf(obj) {
66
61
  return Object.values(obj);
67
62
  }
68
- __name(valuesOf, 'valuesOf');
63
+ __name(valuesOf, "valuesOf");
69
64
 
70
65
  // ../map/src/mapGetOrDefault.ts
71
66
  function mapGetOrDefault(map, key, factory) {
@@ -77,27 +72,27 @@ function mapGetOrDefault(map, key, factory) {
77
72
  map.set(key, value);
78
73
  return value;
79
74
  }
80
- __name(mapGetOrDefault, 'mapGetOrDefault');
75
+ __name(mapGetOrDefault, "mapGetOrDefault");
81
76
 
82
77
  // ../map/src/TimeoutWeakMap.ts
83
78
  var TimeoutWeakMap = class {
84
79
  static {
85
- __name(this, 'TimeoutWeakMap');
80
+ __name(this, "TimeoutWeakMap");
86
81
  }
87
82
  timeoutMs;
88
83
  wmap = /* @__PURE__ */ new WeakMap();
89
84
  /**
90
- * @param timeoutMs Default timeout in milliseconds for entries
91
- */
85
+ * @param timeoutMs Default timeout in milliseconds for entries
86
+ */
92
87
  constructor(timeoutMs) {
93
88
  this.timeoutMs = timeoutMs;
94
89
  }
95
90
  /**
96
- * Retrieves the value for the given key and refreshes its timeout.
97
- *
98
- * @param key The key to retrieve
99
- * @returns The value if found, undefined otherwise
100
- */
91
+ * Retrieves the value for the given key and refreshes its timeout.
92
+ *
93
+ * @param key The key to retrieve
94
+ * @returns The value if found, undefined otherwise
95
+ */
101
96
  get(key) {
102
97
  const vt = this.wmap.get(key);
103
98
  if (!vt) {
@@ -108,28 +103,28 @@ var TimeoutWeakMap = class {
108
103
  return value;
109
104
  }
110
105
  /**
111
- * Sets a key-value pair with an optional custom timeout.
112
- *
113
- * @param key The key to set
114
- * @param value The value to associate with the key
115
- * @param timeoutMs Optional timeout override for this entry
116
- * @returns This instance for chaining
117
- */
106
+ * Sets a key-value pair with an optional custom timeout.
107
+ *
108
+ * @param key The key to set
109
+ * @param value The value to associate with the key
110
+ * @param timeoutMs Optional timeout override for this entry
111
+ * @returns This instance for chaining
112
+ */
118
113
  set(key, value, timeoutMs) {
119
114
  this.wmap.set(key, [
120
115
  value,
121
116
  setTimeout(() => {
122
117
  this.delete(key);
123
- }, timeoutMs ?? this.timeoutMs).unref(),
118
+ }, timeoutMs ?? this.timeoutMs).unref()
124
119
  ]);
125
120
  return this;
126
121
  }
127
122
  /**
128
- * Removes a key-value pair and clears its timeout.
129
- *
130
- * @param key The key to delete
131
- * @returns True if the key existed and was deleted, false otherwise
132
- */
123
+ * Removes a key-value pair and clears its timeout.
124
+ *
125
+ * @param key The key to delete
126
+ * @returns True if the key existed and was deleted, false otherwise
127
+ */
133
128
  delete(key) {
134
129
  const vt = this.wmap.get(key);
135
130
  if (!vt) {
@@ -140,22 +135,22 @@ var TimeoutWeakMap = class {
140
135
  return this.wmap.delete(key);
141
136
  }
142
137
  /**
143
- * Checks if a key exists in the map.
144
- * Does not refresh the timeout.
145
- *
146
- * @param key The key to check
147
- * @returns True if the key exists, false otherwise
148
- */
138
+ * Checks if a key exists in the map.
139
+ * Does not refresh the timeout.
140
+ *
141
+ * @param key The key to check
142
+ * @returns True if the key exists, false otherwise
143
+ */
149
144
  has(key) {
150
145
  return this.wmap.has(key);
151
146
  }
152
147
  /**
153
- * Loads multiple key-value pairs into the map.
154
- *
155
- * @param entries Iterable of key-value pairs to load
156
- * @param timeoutMs Optional timeout override for all entries
157
- * @returns This instance for chaining
158
- */
148
+ * Loads multiple key-value pairs into the map.
149
+ *
150
+ * @param entries Iterable of key-value pairs to load
151
+ * @param timeoutMs Optional timeout override for all entries
152
+ * @returns This instance for chaining
153
+ */
159
154
  load(entries, timeoutMs) {
160
155
  for (const [key, value] of entries) {
161
156
  this.set(key, value, timeoutMs);
@@ -163,24 +158,24 @@ var TimeoutWeakMap = class {
163
158
  return this;
164
159
  }
165
160
  /**
166
- * Updates an existing value or creates a new one using an update function.
167
- *
168
- * @param key The key to update
169
- * @param update Function that receives the current value and returns the new value
170
- * @returns This instance for chaining
171
- */
161
+ * Updates an existing value or creates a new one using an update function.
162
+ *
163
+ * @param key The key to update
164
+ * @param update Function that receives the current value and returns the new value
165
+ * @returns This instance for chaining
166
+ */
172
167
  update(key, update) {
173
168
  return this.set(key, update(this.get(key), key, this));
174
169
  }
175
170
  /**
176
- * Gets a value or creates it using a factory function if it doesn't exist.
177
- * Refreshes timeout if the value exists.
178
- *
179
- * @param key The key to get or create
180
- * @param factory Function to create the value if it doesn't exist
181
- * @param timeoutMs Optional timeout override for new entries
182
- * @returns The existing or newly created value
183
- */
171
+ * Gets a value or creates it using a factory function if it doesn't exist.
172
+ * Refreshes timeout if the value exists.
173
+ *
174
+ * @param key The key to get or create
175
+ * @param factory Function to create the value if it doesn't exist
176
+ * @param timeoutMs Optional timeout override for new entries
177
+ * @returns The existing or newly created value
178
+ */
184
179
  getOrDefault(key, factory, timeoutMs) {
185
180
  const vt = this.wmap.get(key);
186
181
  if (vt) {
@@ -195,28 +190,25 @@ var TimeoutWeakMap = class {
195
190
  }
196
191
  };
197
192
  function memoizeSync(arg = {}) {
198
- const opts =
199
- typeof arg === 'object'
200
- ? arg
201
- : {
202
- maxAge: typeof arg === 'number' ? arg : ms(arg),
203
- };
193
+ const opts = typeof arg === "object" ? arg : {
194
+ maxAge: typeof arg === "number" ? arg : ms(arg)
195
+ };
204
196
  return /* @__PURE__ */ __name(function decorator(target, key, descriptor) {
205
197
  if (!descriptor) {
206
- throw new TypeError('descriptor is undefined');
198
+ throw new TypeError("descriptor is undefined");
207
199
  }
208
200
  const orig = descriptor.value;
209
201
  assertDescriptorValueIsFunction(key, descriptor);
210
202
  const options = {
211
203
  length: false,
212
- ...opts,
204
+ ...opts
213
205
  };
214
206
  if (opts.instancesShareCache) {
215
- Reflect.deleteProperty(options, 'instancesShareCache');
207
+ Reflect.deleteProperty(options, "instancesShareCache");
216
208
  descriptor.value = memoizee(orig, options);
217
209
  } else {
218
210
  const wmap = /* @__PURE__ */ new WeakMap();
219
- descriptor.value = function (...args) {
211
+ descriptor.value = function(...args) {
220
212
  const memoized = mapGetOrDefault(wmap, this, () => {
221
213
  return memoizee(orig, options);
222
214
  });
@@ -224,24 +216,24 @@ function memoizeSync(arg = {}) {
224
216
  };
225
217
  }
226
218
  return descriptor;
227
- }, 'decorator');
219
+ }, "decorator");
228
220
  }
229
- __name(memoizeSync, 'memoizeSync');
221
+ __name(memoizeSync, "memoizeSync");
230
222
  function lazyProp(targetOrTimeout, key, descriptor) {
231
- if (typeof targetOrTimeout === 'number' || typeof targetOrTimeout === 'string') {
232
- const maxAge = typeof targetOrTimeout === 'number' ? targetOrTimeout : ms(targetOrTimeout);
223
+ if (typeof targetOrTimeout === "number" || typeof targetOrTimeout === "string") {
224
+ const maxAge = typeof targetOrTimeout === "number" ? targetOrTimeout : ms(targetOrTimeout);
233
225
  return createLazyPropDecorator(new TimeoutWeakMap(maxAge));
234
226
  } else {
235
227
  const decorator = createLazyPropDecorator(/* @__PURE__ */ new WeakMap());
236
228
  return decorator(targetOrTimeout, key, descriptor);
237
229
  }
238
230
  }
239
- __name(lazyProp, 'lazyProp');
231
+ __name(lazyProp, "lazyProp");
240
232
  function createLazyPropDecorator(map) {
241
- return function (target, key, descriptor) {
233
+ return function(target, key, descriptor) {
242
234
  const { get, value } = descriptor;
243
235
  if (isFunction(get)) {
244
- descriptor.get = function () {
236
+ descriptor.get = function() {
245
237
  return mapGetOrDefault(map, this, () => {
246
238
  return get.call(this);
247
239
  });
@@ -254,34 +246,23 @@ function createLazyPropDecorator(map) {
254
246
  throw new TypeError('neither "get" nor "value" are functions');
255
247
  };
256
248
  }
257
- __name(createLazyPropDecorator, 'createLazyPropDecorator');
249
+ __name(createLazyPropDecorator, "createLazyPropDecorator");
258
250
 
259
251
  // src/lib/Help.ts
260
252
  function _ts_decorate(decorators, target, key, desc) {
261
- var c = arguments.length,
262
- r = c < 3 ? target : desc === null ? (desc = Object.getOwnPropertyDescriptor(target, key)) : desc,
263
- d;
264
- if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') {
265
- r = Reflect.decorate(decorators, target, key, desc);
266
- } else {
267
- for (var i = decorators.length - 1; i >= 0; i--) {
268
- if ((d = decorators[i])) {
269
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
270
- }
271
- }
272
- }
273
- return (c > 3 && r && Object.defineProperty(target, key, r), r);
253
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
254
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
255
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
256
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
274
257
  }
275
- __name(_ts_decorate, '_ts_decorate');
258
+ __name(_ts_decorate, "_ts_decorate");
276
259
  function _ts_metadata(k, v) {
277
- if (typeof Reflect === 'object' && typeof Reflect.metadata === 'function') {
278
- return Reflect.metadata(k, v);
279
- }
260
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
280
261
  }
281
- __name(_ts_metadata, '_ts_metadata');
262
+ __name(_ts_metadata, "_ts_metadata");
282
263
  var Help = class {
283
264
  static {
284
- __name(this, 'Help');
265
+ __name(this, "Help");
285
266
  }
286
267
  cmd;
287
268
  /** output helpWidth, long lines are wrapped to fit */
@@ -289,17 +270,17 @@ var Help = class {
289
270
  minWidthToWrap = 40;
290
271
  sortSubcommands = true;
291
272
  sortOptions = true;
292
- usageDisplayOptionsAs = '[opts]';
293
- usageDisplaySubcommandAs = '[cmd]';
273
+ usageDisplayOptionsAs = "[opts]";
274
+ usageDisplaySubcommandAs = "[cmd]";
294
275
  constructor(cmd) {
295
276
  this.cmd = cmd;
296
- Object.defineProperty(this, 'cmd', {
297
- enumerable: false,
277
+ Object.defineProperty(this, "cmd", {
278
+ enumerable: false
298
279
  });
299
280
  }
300
281
  /**
301
- * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
302
- */
282
+ * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
283
+ */
303
284
  visibleCommands() {
304
285
  const res = Object.values(this.cmd.commands).filter((c) => {
305
286
  return !c.hidden;
@@ -312,17 +293,17 @@ var Help = class {
312
293
  return res;
313
294
  }
314
295
  /**
315
- * Compare options for sort.
316
- */
296
+ * Compare options for sort.
297
+ */
317
298
  compareOptions(a, b) {
318
299
  const getSortKey = /* @__PURE__ */ __name((option) => {
319
- return option.short ? option.short.replace(/^-/, '') : option.long.replace(/^--/, '');
320
- }, 'getSortKey');
300
+ return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
301
+ }, "getSortKey");
321
302
  return getSortKey(a).localeCompare(getSortKey(b));
322
303
  }
323
304
  /**
324
- * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
325
- */
305
+ * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
306
+ */
326
307
  visibleOptions() {
327
308
  const res = this.cmd.options.filter((option) => {
328
309
  return !option.hidden;
@@ -333,131 +314,115 @@ var Help = class {
333
314
  return res;
334
315
  }
335
316
  /**
336
- * Get an array of the arguments if any have a description.
337
- */
317
+ * Get an array of the arguments if any have a description.
318
+ */
338
319
  visibleArguments() {
339
320
  return this.cmd.arguments.slice();
340
321
  }
341
322
  /**
342
- * Get the command term to show in the list of subcommands.
343
- */
323
+ * Get the command term to show in the list of subcommands.
324
+ */
344
325
  subcommandTerm(sub) {
345
- const args = sub.arguments
346
- .map((arg) => {
347
- return arg.usage;
348
- })
349
- .join(' ');
350
- return (
351
- (sub.aliases[0] ? `${sub.aliases[0].padEnd(this.longestSubcommandAliasLength(), ' ')} | ` : '') +
352
- sub.name +
353
- (sub.options.length ? ` ${this.usageDisplayOptionsAs}` : '') + // simplistic check for non-help option
354
- (args ? ` ${args}` : '')
355
- );
326
+ const args = sub.arguments.map((arg) => {
327
+ return arg.usage;
328
+ }).join(" ");
329
+ return (sub.aliases[0] ? `${sub.aliases[0].padEnd(this.longestSubcommandAliasLength(), " ")} | ` : "") + sub.name + (sub.options.length ? ` ${this.usageDisplayOptionsAs}` : "") + // simplistic check for non-help option
330
+ (args ? ` ${args}` : "");
356
331
  }
357
332
  /**
358
- * Get the option term to show in the list of options.
359
- */
333
+ * Get the option term to show in the list of options.
334
+ */
360
335
  optionTerm(option) {
361
336
  return option.flags;
362
337
  }
363
338
  /**
364
- * Get the argument term to show in the list of arguments.
365
- */
339
+ * Get the argument term to show in the list of arguments.
340
+ */
366
341
  argumentTerm(argument) {
367
342
  return argument.usage;
368
343
  }
369
344
  /**
370
- * Get the longest subcommand primary alias length.
371
- */
345
+ * Get the longest subcommand primary alias length.
346
+ */
372
347
  longestSubcommandAliasLength() {
373
- return Math.max(
374
- 0,
375
- ...this.visibleCommands().map((c) => {
376
- return c.aliases[0]?.length || 0;
377
- }),
378
- );
348
+ return Math.max(0, ...this.visibleCommands().map((c) => {
349
+ return c.aliases[0]?.length || 0;
350
+ }));
379
351
  }
380
352
  /**
381
- * Get the longest subcommand term length.
382
- */
353
+ * Get the longest subcommand term length.
354
+ */
383
355
  longestSubcommandTermLength() {
384
356
  return this.visibleCommands().reduce((max, command) => {
385
357
  return Math.max(max, this.displayWidth(this.styleSubcommandTerm(this.subcommandTerm(command))));
386
358
  }, 0);
387
359
  }
388
360
  /**
389
- * Get the longest option term length.
390
- */
361
+ * Get the longest option term length.
362
+ */
391
363
  longestOptionTermLength() {
392
364
  return this.visibleOptions().reduce((max, option) => {
393
365
  return Math.max(max, this.displayWidth(this.styleOptionTerm(this.optionTerm(option))));
394
366
  }, 0);
395
367
  }
396
368
  /**
397
- * Get the longest argument term length.
398
- */
369
+ * Get the longest argument term length.
370
+ */
399
371
  longestArgumentTermLength() {
400
372
  return this.visibleArguments().reduce((max, argument) => {
401
373
  return Math.max(max, this.displayWidth(this.styleArgumentTerm(this.argumentTerm(argument))));
402
374
  }, 0);
403
375
  }
404
376
  /**
405
- * Get the command usage to be displayed at the top of the built-in help.
406
- */
377
+ * Get the command usage to be displayed at the top of the built-in help.
378
+ */
407
379
  commandUsage() {
408
- let path = '';
380
+ let path = "";
409
381
  for (let ancestor = this.cmd.parent; ancestor; ancestor = ancestor.parent) {
410
382
  path = `${ancestor.name} ${path}`;
411
383
  }
412
384
  return `${path + this.cmd.name} ${[
413
- ...(Object.keys(this.cmd.commands).length ? [this.usageDisplaySubcommandAs] : []),
414
- ...(this.cmd.options.length ? [this.usageDisplayOptionsAs] : []),
385
+ ...Object.keys(this.cmd.commands).length ? [
386
+ this.usageDisplaySubcommandAs
387
+ ] : [],
388
+ ...this.cmd.options.length ? [
389
+ this.usageDisplayOptionsAs
390
+ ] : [],
415
391
  ...this.cmd.arguments.map((arg) => {
416
- return arg.required
417
- ? arg.variadic
418
- ? `<${arg.name}...>`
419
- : `<${arg.name}>`
420
- : arg.variadic
421
- ? `[${arg.name}...]`
422
- : `[${arg.name}]`;
423
- }),
424
- ].join(' ')}`.trim();
392
+ return arg.required ? arg.variadic ? `<${arg.name}...>` : `<${arg.name}>` : arg.variadic ? `[${arg.name}...]` : `[${arg.name}]`;
393
+ })
394
+ ].join(" ")}`.trim();
425
395
  }
426
396
  /**
427
- * Get the description for the command.
428
- */
397
+ * Get the description for the command.
398
+ */
429
399
  commandDescription() {
430
- let res = '';
400
+ let res = "";
431
401
  if (this.cmd.aliases.length) {
432
- res += `Aliases: ${this.cmd.aliases.join(', ')}`;
433
- res += '\n\n';
402
+ res += `Aliases: ${this.cmd.aliases.join(", ")}`;
403
+ res += "\n\n";
434
404
  }
435
405
  res += this.cmd.description;
436
406
  return res;
437
407
  }
438
408
  /**
439
- * Get the subcommand summary to show in the list of subcommands.
440
- * (Fallback to description for backwards compatibility.)
441
- */
409
+ * Get the subcommand summary to show in the list of subcommands.
410
+ * (Fallback to description for backwards compatibility.)
411
+ */
442
412
  subcommandDescription(sub) {
443
- return (
444
- sub.summary ||
445
- (sub.description?.includes('\n') ? sub.description.trim().split('\n')[0] : sub.description.trim())
446
- );
413
+ return sub.summary || (sub.description?.includes("\n") ? sub.description.trim().split("\n")[0] : sub.description.trim());
447
414
  }
448
415
  /**
449
- * Get the option description to show in the list of options.
450
- */
416
+ * Get the option description to show in the list of options.
417
+ */
451
418
  optionDescription(option) {
452
419
  const extraInfo = [];
453
420
  if (option.choices) {
454
421
  extraInfo.push(
455
422
  // use stringify to match the display of the default value
456
- `choices: ${option.choices
457
- .map((choice) => {
458
- return String(choice);
459
- })
460
- .join(', ')}`,
423
+ `choices: ${option.choices.map((choice) => {
424
+ return String(choice);
425
+ }).join(", ")}`
461
426
  );
462
427
  }
463
428
  if (option.defaultValue && !(Array.isArray(option.defaultValue) && option.defaultValue.length === 0)) {
@@ -467,53 +432,55 @@ var Help = class {
467
432
  extraInfo.push(`env: ${option.env}`);
468
433
  }
469
434
  if (extraInfo.length > 0) {
470
- const extraDescription = `(${extraInfo.join(', ')})`;
435
+ const extraDescription = `(${extraInfo.join(", ")})`;
471
436
  if (option.description) {
472
437
  return `${option.description} ${extraDescription}`;
473
438
  }
474
439
  return extraDescription;
475
440
  }
476
- return option.description ?? '';
441
+ return option.description ?? "";
477
442
  }
478
443
  /**
479
- * Get the argument description to show in the list of arguments.
480
- */
444
+ * Get the argument description to show in the list of arguments.
445
+ */
481
446
  argumentDescription(argument) {
482
447
  const extraInfo = [];
483
448
  if (argument.choices) {
484
449
  extraInfo.push(
485
450
  // use stringify to match the display of the default value
486
- `choices: ${argument.choices
487
- .map((choice) => {
488
- return String(choice);
489
- })
490
- .join(', ')}`,
451
+ `choices: ${argument.choices.map((choice) => {
452
+ return String(choice);
453
+ }).join(", ")}`
491
454
  );
492
455
  }
493
456
  if (argument.defaultValue && !(Array.isArray(argument.defaultValue) && argument.defaultValue.length === 0)) {
494
457
  extraInfo.push(`default: ${argument.defaultValueDescription || String(argument.defaultValue)}`);
495
458
  }
496
459
  if (extraInfo.length > 0) {
497
- const extraDescription = `(${extraInfo.join(', ')})`;
460
+ const extraDescription = `(${extraInfo.join(", ")})`;
498
461
  if (argument.description) {
499
462
  return `${argument.description} ${extraDescription}`;
500
463
  }
501
464
  return extraDescription;
502
465
  }
503
- return argument.description ?? '';
466
+ return argument.description ?? "";
504
467
  }
505
468
  /**
506
- * Format a list of items, given a heading and an array of formatted items.
507
- */
469
+ * Format a list of items, given a heading and an array of formatted items.
470
+ */
508
471
  formatItemList(heading, items) {
509
472
  if (items.length === 0) {
510
473
  return [];
511
474
  }
512
- return [this.styleTitle(heading), ...items, ''];
475
+ return [
476
+ this.styleTitle(heading),
477
+ ...items,
478
+ ""
479
+ ];
513
480
  }
514
481
  /**
515
- * Group items by their help group heading.
516
- */
482
+ * Group items by their help group heading.
483
+ */
517
484
  groupItems(unsortedItems, visibleItems, getGroup) {
518
485
  const result = /* @__PURE__ */ new Map();
519
486
  unsortedItems.forEach((item) => {
@@ -532,159 +499,149 @@ var Help = class {
532
499
  return result;
533
500
  }
534
501
  /**
535
- * Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations.
536
- */
502
+ * Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations.
503
+ */
537
504
  displayWidth(str) {
538
505
  const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
539
- return str.replace(sgrPattern, '').length;
506
+ return str.replace(sgrPattern, "").length;
540
507
  }
541
508
  /**
542
- * Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc.
543
- */
509
+ * Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc.
510
+ */
544
511
  styleTitle(str) {
545
512
  return C.yellow(str);
546
513
  }
547
514
  /**
548
- * Style the usage line for displaying in the help. Applies specific styling to different parts like options, commands, and arguments.
549
- */
515
+ * Style the usage line for displaying in the help. Applies specific styling to different parts like options, commands, and arguments.
516
+ */
550
517
  styleUsage(str) {
551
- return str
552
- .split(' ')
553
- .map((word, index, arr) => {
554
- if (word === this.usageDisplaySubcommandAs) {
555
- return C.green(word);
556
- }
557
- if (word === this.usageDisplayOptionsAs) {
558
- return C.blue(word);
559
- }
560
- if (word[0] === '<') {
561
- return C.red(word);
562
- }
563
- if (word[0] === '[') {
564
- return C.cyan(word);
565
- }
566
- if (arr[index + 1]?.startsWith('[')) {
567
- return C.magenta(word);
568
- }
569
- return this.styleCommandText(word);
570
- })
571
- .join(' ');
518
+ return str.split(" ").map((word, index, arr) => {
519
+ if (word === this.usageDisplaySubcommandAs) {
520
+ return C.green(word);
521
+ }
522
+ if (word === this.usageDisplayOptionsAs) {
523
+ return C.blue(word);
524
+ }
525
+ if (word[0] === "<") {
526
+ return C.red(word);
527
+ }
528
+ if (word[0] === "[") {
529
+ return C.cyan(word);
530
+ }
531
+ if (arr[index + 1]?.startsWith("[")) {
532
+ return C.magenta(word);
533
+ }
534
+ return this.styleCommandText(word);
535
+ }).join(" ");
572
536
  }
573
537
  /**
574
- * Style command descriptions for display in help output.
575
- */
538
+ * Style command descriptions for display in help output.
539
+ */
576
540
  styleCommandDescription(str) {
577
541
  return this.styleDescriptionText(str);
578
542
  }
579
543
  /**
580
- * Style option descriptions for display in help output.
581
- */
544
+ * Style option descriptions for display in help output.
545
+ */
582
546
  styleOptionDescription(str) {
583
547
  return C.gray(this.styleDescriptionText(str));
584
548
  }
585
549
  /**
586
- * Style subcommand descriptions for display in help output.
587
- */
550
+ * Style subcommand descriptions for display in help output.
551
+ */
588
552
  styleSubcommandDescription(str) {
589
553
  return this.styleDescriptionText(str);
590
554
  }
591
555
  /**
592
- * Style argument descriptions for display in help output.
593
- */
556
+ * Style argument descriptions for display in help output.
557
+ */
594
558
  styleArgumentDescription(str) {
595
559
  return C.gray(this.styleDescriptionText(str));
596
560
  }
597
561
  /**
598
- * Base style used by descriptions. Override in subclass to apply custom formatting.
599
- */
562
+ * Base style used by descriptions. Override in subclass to apply custom formatting.
563
+ */
600
564
  styleDescriptionText(str) {
601
565
  return C.gray(str);
602
566
  }
603
567
  /**
604
- * Style option terms (flags) for display in help output.
605
- */
568
+ * Style option terms (flags) for display in help output.
569
+ */
606
570
  styleOptionTerm(str) {
607
571
  return this.styleOptionText(str);
608
572
  }
609
573
  /**
610
- * Style subcommand terms for display in help output. Applies specific styling to different parts like options and arguments.
611
- */
574
+ * Style subcommand terms for display in help output. Applies specific styling to different parts like options and arguments.
575
+ */
612
576
  styleSubcommandTerm(str) {
613
- const res = str
614
- .split(' ')
615
- .map((word) => {
616
- if (word === this.usageDisplayOptionsAs) {
617
- return C.dim(word);
618
- }
619
- if (word[0] === '[' || word[0] === '<') {
620
- return C.dim(word);
621
- }
622
- return this.styleSubcommandText(word);
623
- })
624
- .join(' ');
625
- const split = res.split('|');
577
+ const res = str.split(" ").map((word) => {
578
+ if (word === this.usageDisplayOptionsAs) {
579
+ return C.dim(word);
580
+ }
581
+ if (word[0] === "[" || word[0] === "<") {
582
+ return C.dim(word);
583
+ }
584
+ return this.styleSubcommandText(word);
585
+ }).join(" ");
586
+ const split = res.split("|");
626
587
  if (split.length === 1) {
627
588
  return res;
628
589
  }
629
590
  split[0] = C.green(split[0]);
630
- return split.join('|');
591
+ return split.join("|");
631
592
  }
632
593
  /**
633
- * Style argument terms for display in help output.
634
- */
594
+ * Style argument terms for display in help output.
595
+ */
635
596
  styleArgumentTerm(str) {
636
597
  return this.styleArgumentText(str);
637
598
  }
638
599
  /**
639
- * Base style used in terms and usage for options. Override in subclass to apply custom formatting.
640
- */
600
+ * Base style used in terms and usage for options. Override in subclass to apply custom formatting.
601
+ */
641
602
  styleOptionText(str) {
642
603
  return str;
643
604
  }
644
605
  /**
645
- * Base style used in terms and usage for arguments. Override in subclass to apply custom formatting.
646
- */
606
+ * Base style used in terms and usage for arguments. Override in subclass to apply custom formatting.
607
+ */
647
608
  styleArgumentText(str) {
648
609
  return str;
649
610
  }
650
611
  /**
651
- * Base style used in terms and usage for subcommands. Override in subclass to apply custom formatting.
652
- */
612
+ * Base style used in terms and usage for subcommands. Override in subclass to apply custom formatting.
613
+ */
653
614
  styleSubcommandText(str) {
654
615
  return str;
655
616
  }
656
617
  /**
657
- * Base style used in terms and usage for commands. Override in subclass to apply custom formatting.
658
- */
618
+ * Base style used in terms and usage for commands. Override in subclass to apply custom formatting.
619
+ */
659
620
  styleCommandText(str) {
660
621
  return str;
661
622
  }
662
623
  /**
663
- * Calculate the pad width from the maximum term length.
664
- */
624
+ * Calculate the pad width from the maximum term length.
625
+ */
665
626
  padWidth() {
666
- return Math.max(
667
- this.longestOptionTermLength(),
668
- this.longestSubcommandTermLength(),
669
- this.longestArgumentTermLength(),
670
- );
627
+ return Math.max(this.longestOptionTermLength(), this.longestSubcommandTermLength(), this.longestArgumentTermLength());
671
628
  }
672
629
  /**
673
- * Detect manually wrapped and indented strings by checking for line break followed by whitespace.
674
- */
630
+ * Detect manually wrapped and indented strings by checking for line break followed by whitespace.
631
+ */
675
632
  preformatted(str) {
676
633
  return /\n[^\S\r\n]/.test(str);
677
634
  }
678
635
  /**
679
- * Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
680
- *
681
- * So "TTT", 5, "DDD DDDD DD DDD" might be formatted for this.helpWidth=17 like so:
682
- * TTT DDD DDDD
683
- * DD DDD
684
- */
636
+ * Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
637
+ *
638
+ * So "TTT", 5, "DDD DDDD DD DDD" might be formatted for this.helpWidth=17 like so:
639
+ * TTT DDD DDDD
640
+ * DD DDD
641
+ */
685
642
  formatItem(term, termWidth, description) {
686
643
  const itemIndent = 2;
687
- const itemIndentStr = ' '.repeat(itemIndent);
644
+ const itemIndentStr = " ".repeat(itemIndent);
688
645
  if (!description) {
689
646
  return itemIndentStr + term;
690
647
  }
@@ -697,27 +654,16 @@ var Help = class {
697
654
  formattedDescription = description;
698
655
  } else {
699
656
  const wrappedDescription = this.boxWrap(description, remainingWidth);
700
- formattedDescription = wrappedDescription.replace(
701
- /\n/g,
702
- `
703
- ${' '.repeat(termWidth + spacerWidth)}`,
704
- );
657
+ formattedDescription = wrappedDescription.replace(/\n/g, `
658
+ ${" ".repeat(termWidth + spacerWidth)}`);
705
659
  }
706
- return (
707
- itemIndentStr +
708
- paddedTerm +
709
- ' '.repeat(spacerWidth) +
710
- formattedDescription.replace(
711
- /\n/g,
712
- `
713
- ${itemIndentStr}`,
714
- )
715
- );
660
+ return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
661
+ ${itemIndentStr}`);
716
662
  }
717
663
  /**
718
- * Wrap a string at whitespace, preserving existing line breaks.
719
- * Wrapping is skipped if the width is less than `minWidthToWrap`.
720
- */
664
+ * Wrap a string at whitespace, preserving existing line breaks.
665
+ * Wrapping is skipped if the width is less than `minWidthToWrap`.
666
+ */
721
667
  boxWrap(str, width) {
722
668
  if (width < this.minWidthToWrap) {
723
669
  return str;
@@ -728,10 +674,12 @@ ${itemIndentStr}`,
728
674
  rawLines.forEach((line) => {
729
675
  const chunks = line.match(chunkPattern);
730
676
  if (chunks === null) {
731
- wrappedLines.push('');
677
+ wrappedLines.push("");
732
678
  return;
733
679
  }
734
- let sumChunks = [chunks.shift()];
680
+ let sumChunks = [
681
+ chunks.shift()
682
+ ];
735
683
  let sumWidth = this.displayWidth(sumChunks[0]);
736
684
  chunks.forEach((chunk) => {
737
685
  const visibleWidth = this.displayWidth(chunk);
@@ -740,181 +688,139 @@ ${itemIndentStr}`,
740
688
  sumWidth += visibleWidth;
741
689
  return;
742
690
  }
743
- wrappedLines.push(sumChunks.join(''));
691
+ wrappedLines.push(sumChunks.join(""));
744
692
  const nextChunk = chunk.trimStart();
745
- sumChunks = [nextChunk];
693
+ sumChunks = [
694
+ nextChunk
695
+ ];
746
696
  sumWidth = this.displayWidth(nextChunk);
747
697
  });
748
- wrappedLines.push(sumChunks.join(''));
698
+ wrappedLines.push(sumChunks.join(""));
749
699
  });
750
- return wrappedLines.join('\n');
700
+ return wrappedLines.join("\n");
751
701
  }
752
702
  /**
753
- * Generate the built-in help text.
754
- */
703
+ * Generate the built-in help text.
704
+ */
755
705
  render() {
756
- let output = [`${this.styleTitle('Usage:')} ${this.styleUsage(this.commandUsage())}`, ''];
706
+ let output = [
707
+ `${this.styleTitle("Usage:")} ${this.styleUsage(this.commandUsage())}`,
708
+ ""
709
+ ];
757
710
  const des = this.commandDescription();
758
711
  if (des.length > 0) {
759
- output = output.concat([this.boxWrap(this.styleCommandDescription(des), this.helpWidth), '']);
712
+ output = output.concat([
713
+ this.boxWrap(this.styleCommandDescription(des), this.helpWidth),
714
+ ""
715
+ ]);
760
716
  }
761
717
  const argumentList = this.visibleArguments().map((argument) => {
762
- return this.formatItem(
763
- this.styleArgumentTerm(this.argumentTerm(argument)),
764
- this.padWidth(),
765
- this.styleArgumentDescription(this.argumentDescription(argument)),
766
- );
718
+ return this.formatItem(this.styleArgumentTerm(this.argumentTerm(argument)), this.padWidth(), this.styleArgumentDescription(this.argumentDescription(argument)));
767
719
  });
768
- output = output.concat(this.formatItemList('Arguments:', argumentList));
720
+ output = output.concat(this.formatItemList("Arguments:", argumentList));
769
721
  const optionGroups = this.groupItems(this.cmd.options, this.visibleOptions(), (option) => {
770
- return option.group ?? 'Options:';
722
+ return option.group ?? "Options:";
771
723
  });
772
724
  optionGroups.forEach((options, group) => {
773
725
  const optionList = options.map((option) => {
774
- return this.formatItem(
775
- this.styleOptionTerm(this.optionTerm(option)),
776
- this.padWidth(),
777
- this.styleOptionDescription(this.optionDescription(option)),
778
- );
726
+ return this.formatItem(this.styleOptionTerm(this.optionTerm(option)), this.padWidth(), this.styleOptionDescription(this.optionDescription(option)));
779
727
  });
780
728
  output = output.concat(this.formatItemList(group, optionList));
781
729
  });
782
730
  const commandGroups = this.groupItems(Object.values(this.cmd.commands), this.visibleCommands(), (sub) => {
783
- return sub.group || 'Commands:';
731
+ return sub.group || "Commands:";
784
732
  });
785
733
  commandGroups.forEach((commands, group) => {
786
734
  const commandList = commands.map((sub) => {
787
- return this.formatItem(
788
- this.styleSubcommandTerm(this.subcommandTerm(sub)),
789
- this.padWidth(),
790
- this.styleSubcommandDescription(this.subcommandDescription(sub)),
791
- );
735
+ return this.formatItem(this.styleSubcommandTerm(this.subcommandTerm(sub)), this.padWidth(), this.styleSubcommandDescription(this.subcommandDescription(sub)));
792
736
  });
793
737
  output = output.concat(this.formatItemList(group, commandList));
794
738
  });
795
- return output.join('\n');
739
+ return output.join("\n");
796
740
  }
797
741
  };
798
- _ts_decorate(
799
- [
800
- lazyProp,
801
- _ts_metadata('design:type', Function),
802
- _ts_metadata('design:paramtypes', []),
803
- _ts_metadata('design:returntype', Array),
804
- ],
805
- Help.prototype,
806
- 'visibleCommands',
807
- null,
808
- );
809
- _ts_decorate(
810
- [
811
- lazyProp,
812
- _ts_metadata('design:type', Function),
813
- _ts_metadata('design:paramtypes', []),
814
- _ts_metadata('design:returntype', Array),
815
- ],
816
- Help.prototype,
817
- 'visibleOptions',
818
- null,
819
- );
820
- _ts_decorate(
821
- [
822
- lazyProp,
823
- _ts_metadata('design:type', Function),
824
- _ts_metadata('design:paramtypes', []),
825
- _ts_metadata('design:returntype', Array),
826
- ],
827
- Help.prototype,
828
- 'visibleArguments',
829
- null,
830
- );
831
- _ts_decorate(
832
- [
833
- lazyProp,
834
- _ts_metadata('design:type', Function),
835
- _ts_metadata('design:paramtypes', []),
836
- _ts_metadata('design:returntype', Number),
837
- ],
838
- Help.prototype,
839
- 'longestSubcommandAliasLength',
840
- null,
841
- );
842
- _ts_decorate(
843
- [
844
- lazyProp,
845
- _ts_metadata('design:type', Function),
846
- _ts_metadata('design:paramtypes', []),
847
- _ts_metadata('design:returntype', Number),
848
- ],
849
- Help.prototype,
850
- 'longestSubcommandTermLength',
851
- null,
852
- );
853
- _ts_decorate(
854
- [
855
- lazyProp,
856
- _ts_metadata('design:type', Function),
857
- _ts_metadata('design:paramtypes', []),
858
- _ts_metadata('design:returntype', Number),
859
- ],
860
- Help.prototype,
861
- 'longestOptionTermLength',
862
- null,
863
- );
864
- _ts_decorate(
865
- [
866
- lazyProp,
867
- _ts_metadata('design:type', Function),
868
- _ts_metadata('design:paramtypes', []),
869
- _ts_metadata('design:returntype', Number),
870
- ],
871
- Help.prototype,
872
- 'longestArgumentTermLength',
873
- null,
874
- );
875
- _ts_decorate(
876
- [
877
- lazyProp,
878
- _ts_metadata('design:type', Function),
879
- _ts_metadata('design:paramtypes', []),
880
- _ts_metadata('design:returntype', Number),
881
- ],
882
- Help.prototype,
883
- 'padWidth',
884
- null,
885
- );
742
+ _ts_decorate([
743
+ lazyProp,
744
+ _ts_metadata("design:type", Function),
745
+ _ts_metadata("design:paramtypes", []),
746
+ _ts_metadata("design:returntype", Array)
747
+ ], Help.prototype, "visibleCommands", null);
748
+ _ts_decorate([
749
+ lazyProp,
750
+ _ts_metadata("design:type", Function),
751
+ _ts_metadata("design:paramtypes", []),
752
+ _ts_metadata("design:returntype", Array)
753
+ ], Help.prototype, "visibleOptions", null);
754
+ _ts_decorate([
755
+ lazyProp,
756
+ _ts_metadata("design:type", Function),
757
+ _ts_metadata("design:paramtypes", []),
758
+ _ts_metadata("design:returntype", Array)
759
+ ], Help.prototype, "visibleArguments", null);
760
+ _ts_decorate([
761
+ lazyProp,
762
+ _ts_metadata("design:type", Function),
763
+ _ts_metadata("design:paramtypes", []),
764
+ _ts_metadata("design:returntype", Number)
765
+ ], Help.prototype, "longestSubcommandAliasLength", null);
766
+ _ts_decorate([
767
+ lazyProp,
768
+ _ts_metadata("design:type", Function),
769
+ _ts_metadata("design:paramtypes", []),
770
+ _ts_metadata("design:returntype", Number)
771
+ ], Help.prototype, "longestSubcommandTermLength", null);
772
+ _ts_decorate([
773
+ lazyProp,
774
+ _ts_metadata("design:type", Function),
775
+ _ts_metadata("design:paramtypes", []),
776
+ _ts_metadata("design:returntype", Number)
777
+ ], Help.prototype, "longestOptionTermLength", null);
778
+ _ts_decorate([
779
+ lazyProp,
780
+ _ts_metadata("design:type", Function),
781
+ _ts_metadata("design:paramtypes", []),
782
+ _ts_metadata("design:returntype", Number)
783
+ ], Help.prototype, "longestArgumentTermLength", null);
784
+ _ts_decorate([
785
+ lazyProp,
786
+ _ts_metadata("design:type", Function),
787
+ _ts_metadata("design:paramtypes", []),
788
+ _ts_metadata("design:returntype", Number)
789
+ ], Help.prototype, "padWidth", null);
886
790
 
887
791
  // ../array/src/lib/arrLast.ts
888
792
  function arrLast(array) {
889
793
  if (!array.length) {
890
- throw new Error('Cannot get last element of empty array.');
794
+ throw new Error("Cannot get last element of empty array.");
891
795
  }
892
796
  return array[array.length - 1];
893
797
  }
894
- __name(arrLast, 'arrLast');
798
+ __name(arrLast, "arrLast");
895
799
 
896
800
  // ../array/src/lib/arrRemoveDuplicates.ts
897
801
  function arrRemoveDuplicates(array) {
898
802
  return Array.from(new Set(array));
899
803
  }
900
- __name(arrRemoveDuplicates, 'arrRemoveDuplicates');
804
+ __name(arrRemoveDuplicates, "arrRemoveDuplicates");
901
805
 
902
806
  // src/lib/internal/collectVariadicOptionValues.ts
903
807
  function collectVariadicOptionValues(parsed, options) {
904
808
  for (let i = 0; i < parsed.tokens.length; i++) {
905
809
  const token = parsed.tokens[i];
906
- if (token.kind !== 'option') {
810
+ if (token.kind !== "option") {
907
811
  continue;
908
812
  }
909
813
  const def = options.find((o) => {
910
814
  return o.name === token.name;
911
815
  });
912
- if (!def?.variadic || def.type !== 'string') {
816
+ if (!def?.variadic || def.type !== "string") {
913
817
  continue;
914
818
  }
915
- const values = [token.value];
819
+ const values = [
820
+ token.value
821
+ ];
916
822
  let j = i + 1;
917
- while (j < parsed.tokens.length && parsed.tokens[j].kind === 'positional') {
823
+ while (j < parsed.tokens.length && parsed.tokens[j].kind === "positional") {
918
824
  const positionalToken = parsed.tokens[j];
919
825
  values.push(positionalToken.value);
920
826
  const posIndex = parsed.positionals.indexOf(positionalToken.value);
@@ -923,43 +829,32 @@ function collectVariadicOptionValues(parsed, options) {
923
829
  }
924
830
  j++;
925
831
  }
926
- Reflect.set(
927
- parsed.values,
928
- token.name,
929
- values.filter((v) => {
930
- return v !== void 0;
931
- }),
932
- );
832
+ Reflect.set(parsed.values, token.name, values.filter((v) => {
833
+ return v !== void 0;
834
+ }));
933
835
  }
934
836
  }
935
- __name(collectVariadicOptionValues, 'collectVariadicOptionValues');
837
+ __name(collectVariadicOptionValues, "collectVariadicOptionValues");
936
838
 
937
839
  // src/lib/helpers/findCommand.ts
938
840
  function findCommand(cmd, nameOrAlias) {
939
- return (
940
- cmd.commands[nameOrAlias] ??
941
- valuesOf(cmd.commands).find((c) => {
942
- return c.aliases.includes(nameOrAlias);
943
- })
944
- );
841
+ return cmd.commands[nameOrAlias] ?? valuesOf(cmd.commands).find((c) => {
842
+ return c.aliases.includes(nameOrAlias);
843
+ });
945
844
  }
946
- __name(findCommand, 'findCommand');
845
+ __name(findCommand, "findCommand");
947
846
 
948
847
  // src/lib/helpers/findOption.ts
949
848
  function findOption(cmd, nameOrShortOrLong) {
950
- return nameOrShortOrLong.startsWith('--')
951
- ? cmd.options.find((o) => {
952
- return o.long === nameOrShortOrLong.slice(2);
953
- })
954
- : nameOrShortOrLong.startsWith('-')
955
- ? cmd.options.find((o) => {
956
- return o.short === nameOrShortOrLong.slice(1);
957
- })
958
- : cmd.options.find((o) => {
959
- return o.name === nameOrShortOrLong;
960
- });
849
+ return nameOrShortOrLong.startsWith("--") ? cmd.options.find((o) => {
850
+ return o.long === nameOrShortOrLong.slice(2);
851
+ }) : nameOrShortOrLong.startsWith("-") ? cmd.options.find((o) => {
852
+ return o.short === nameOrShortOrLong.slice(1);
853
+ }) : cmd.options.find((o) => {
854
+ return o.name === nameOrShortOrLong;
855
+ });
961
856
  }
962
- __name(findOption, 'findOption');
857
+ __name(findOption, "findOption");
963
858
 
964
859
  // src/lib/helpers/getCommandAndAncestors.ts
965
860
  function getCommandAndAncestors(cmd) {
@@ -970,13 +865,13 @@ function getCommandAndAncestors(cmd) {
970
865
  }
971
866
  return result;
972
867
  }
973
- __name(getCommandAndAncestors, 'getCommandAndAncestors');
868
+ __name(getCommandAndAncestors, "getCommandAndAncestors");
974
869
 
975
870
  // src/lib/helpers/getCommandAncestors.ts
976
871
  function getCommandAncestors(cmd) {
977
872
  return getCommandAndAncestors(cmd).slice(1);
978
873
  }
979
- __name(getCommandAncestors, 'getCommandAncestors');
874
+ __name(getCommandAncestors, "getCommandAncestors");
980
875
 
981
876
  // src/lib/internal/mergeOptionDefaults.ts
982
877
  function mergeOptionDefaults(values, options) {
@@ -986,7 +881,7 @@ function mergeOptionDefaults(values, options) {
986
881
  }
987
882
  }
988
883
  }
989
- __name(mergeOptionDefaults, 'mergeOptionDefaults');
884
+ __name(mergeOptionDefaults, "mergeOptionDefaults");
990
885
 
991
886
  // src/lib/internal/normalizeArgv.ts
992
887
  function normalizeArgv(argv, options) {
@@ -1006,7 +901,7 @@ function normalizeArgv(argv, options) {
1006
901
  }
1007
902
  return argv;
1008
903
  }
1009
- __name(normalizeArgv, 'normalizeArgv');
904
+ __name(normalizeArgv, "normalizeArgv");
1010
905
 
1011
906
  // src/lib/helpers/parseOptionFlags.ts
1012
907
  function parseOptionFlags(flags) {
@@ -1019,18 +914,18 @@ function parseOptionFlags(flags) {
1019
914
  throw new Error(`Expected short name to be a single character. Got: -${short}`);
1020
915
  }
1021
916
  const long = match[2];
1022
- const argName = (match[4] || match[5])?.replace(/\.\.\.$/, '') || void 0;
1023
- const name = long.split('-').reduce((str, word) => {
917
+ const argName = (match[4] || match[5])?.replace(/\.\.\.$/, "") || void 0;
918
+ const name = long.split("-").reduce((str, word) => {
1024
919
  return str + word[0].toUpperCase() + word.slice(1);
1025
920
  });
1026
921
  return {
1027
922
  short,
1028
923
  long,
1029
924
  name,
1030
- argName,
925
+ argName
1031
926
  };
1032
927
  }
1033
- __name(parseOptionFlags, 'parseOptionFlags');
928
+ __name(parseOptionFlags, "parseOptionFlags");
1034
929
 
1035
930
  // src/lib/internal/resolveArguments.ts
1036
931
  function resolveArguments(positionals, args) {
@@ -1046,61 +941,82 @@ function resolveArguments(positionals, args) {
1046
941
  }
1047
942
  return result;
1048
943
  }
1049
- __name(resolveArguments, 'resolveArguments');
944
+ __name(resolveArguments, "resolveArguments");
1050
945
 
1051
946
  // ../fn/src/setName.ts
1052
947
  function setName(name, target) {
1053
- return Object.defineProperty(target, 'name', {
1054
- value: typeof name === 'string' ? name : name.name,
948
+ return Object.defineProperty(target, "name", {
949
+ value: typeof name === "string" ? name : name.name,
1055
950
  configurable: true,
1056
- enumerable: false,
951
+ enumerable: false
1057
952
  });
1058
953
  }
1059
- __name(setName, 'setName');
954
+ __name(setName, "setName");
1060
955
 
1061
956
  // ../string/src/lib/strFirstCharToUpperCase.ts
1062
957
  function strFirstCharToUpperCase(string) {
1063
958
  return string.charAt(0).toUpperCase() + string.substring(1);
1064
959
  }
1065
- __name(strFirstCharToUpperCase, 'strFirstCharToUpperCase');
960
+ __name(strFirstCharToUpperCase, "strFirstCharToUpperCase");
1066
961
  function createLogger(name) {
1067
962
  const NAME = name ? C.dim.cyan(name) : name;
1068
- const START = [NAME, C.dim.gray('[START]')].filter(Boolean);
1069
- const DEBUG = [NAME, C.dim.magenta('[DEBUG]')].filter(Boolean);
1070
- const INFO = [NAME, C.dim.gray('[INFO]')].filter(Boolean);
1071
- const DONE = [NAME, C.dim.green('[DONE] ')].filter(Boolean);
1072
- const WARN = [NAME, C.dim.yellow('[WARN] ')].filter(Boolean);
1073
- const ERROR = [NAME, C.dim.red('[ERROR]')].filter(Boolean);
963
+ const START = [
964
+ NAME,
965
+ C.dim.gray("[START]")
966
+ ].filter(Boolean);
967
+ const DEBUG = [
968
+ NAME,
969
+ C.dim.magenta("[DEBUG]")
970
+ ].filter(Boolean);
971
+ const INFO = [
972
+ NAME,
973
+ C.dim.gray("[INFO]")
974
+ ].filter(Boolean);
975
+ const DONE = [
976
+ NAME,
977
+ C.dim.green("[DONE] ")
978
+ ].filter(Boolean);
979
+ const WARN = [
980
+ NAME,
981
+ C.dim.yellow("[WARN] ")
982
+ ].filter(Boolean);
983
+ const ERROR = [
984
+ NAME,
985
+ C.dim.red("[ERROR]")
986
+ ].filter(Boolean);
1074
987
  const grayArgs = createColoredArgs(C.gray);
1075
988
  const cyanArgs = createColoredArgs(C.cyan);
1076
989
  const yellowArgs = createColoredArgs(C.yellow);
1077
990
  return {
1078
991
  start: /* @__PURE__ */ __name((...args) => {
1079
992
  return console.info(...START, ...args);
1080
- }, 'start'),
993
+ }, "start"),
1081
994
  done: /* @__PURE__ */ __name((...args) => {
1082
995
  return console.info(...DONE, ...args);
1083
- }, 'done'),
996
+ }, "done"),
1084
997
  info: /* @__PURE__ */ __name((...args) => {
1085
998
  return console.info(...INFO, ...grayArgs(args));
1086
- }, 'info'),
999
+ }, "info"),
1087
1000
  log: /* @__PURE__ */ __name((...args) => {
1088
- return console.log(...(NAME ? [NAME, ...args] : args));
1089
- }, 'log'),
1001
+ return console.log(...NAME ? [
1002
+ NAME,
1003
+ ...args
1004
+ ] : args);
1005
+ }, "log"),
1090
1006
  warn: /* @__PURE__ */ __name((...args) => {
1091
1007
  return console.warn(...WARN, ...yellowArgs(args));
1092
- }, 'warn'),
1008
+ }, "warn"),
1093
1009
  debug: /* @__PURE__ */ __name((...args) => {
1094
1010
  return console.debug(...DEBUG, ...cyanArgs(args));
1095
- }, 'debug'),
1011
+ }, "debug"),
1096
1012
  error: /* @__PURE__ */ __name((...args) => {
1097
1013
  return args.forEach((arg) => {
1098
1014
  return console.error(...ERROR, arg);
1099
1015
  });
1100
- }, 'error'),
1016
+ }, "error")
1101
1017
  };
1102
1018
  }
1103
- __name(createLogger, 'createLogger');
1019
+ __name(createLogger, "createLogger");
1104
1020
  function createColoredArgs(colorFn) {
1105
1021
  return (args) => {
1106
1022
  return args.map((arg) => {
@@ -1118,10 +1034,13 @@ function createColoredArgs(colorFn) {
1118
1034
  });
1119
1035
  };
1120
1036
  }
1121
- __name(createColoredArgs, 'createColoredArgs');
1037
+ __name(createColoredArgs, "createColoredArgs");
1122
1038
  function timer(arg, task) {
1123
1039
  const t0 = process.hrtime.bigint();
1124
- const [name, description] = Array.isArray(arg) ? arg : [arg, ''];
1040
+ const [name, description] = Array.isArray(arg) ? arg : [
1041
+ arg,
1042
+ ""
1043
+ ];
1125
1044
  const log = createLogger(name);
1126
1045
  if (name && description) {
1127
1046
  log.start(description);
@@ -1143,93 +1062,69 @@ function timer(arg, task) {
1143
1062
  return retval2;
1144
1063
  }
1145
1064
  }
1146
- __name(timer, 'timer');
1065
+ __name(timer, "timer");
1147
1066
 
1148
1067
  // src/lib/internal/validateParsed.ts
1149
1068
  function validateParsed(args, optionValues, argDefs, optionDefs) {
1150
- return argDefs
1151
- .map((def, index) => {
1152
- const value = args[index];
1153
- if (def.required) {
1154
- if (def.variadic ? Array.isArray(value) && value.length === 0 : value === void 0) {
1155
- return `Missing argument [${index}] ${def.usage}`;
1156
- }
1069
+ return argDefs.map((def, index) => {
1070
+ const value = args[index];
1071
+ if (def.required) {
1072
+ if (def.variadic ? Array.isArray(value) && value.length === 0 : value === void 0) {
1073
+ return `Missing argument [${index}] ${def.usage}`;
1157
1074
  }
1158
- if (def.choices && value !== void 0) {
1159
- if (
1160
- ![value].flat().every((v) => {
1161
- return def.choices.includes(v);
1162
- })
1163
- ) {
1164
- return `Invalid argument [${index}] ${def.usage}: Got \`${value}\`. Accepted values: [${def.choices
1165
- .map((c) => {
1166
- return `\`${c}\``;
1167
- })
1168
- .join(',')}]`;
1169
- }
1075
+ }
1076
+ if (def.choices && value !== void 0) {
1077
+ if (![
1078
+ value
1079
+ ].flat().every((v) => {
1080
+ return def.choices.includes(v);
1081
+ })) {
1082
+ return `Invalid argument [${index}] ${def.usage}: Got \`${value}\`. Accepted values: [${def.choices.map((c) => {
1083
+ return `\`${c}\``;
1084
+ }).join(",")}]`;
1170
1085
  }
1171
- })
1172
- .concat(
1173
- entriesOf(optionValues).map(([key, value]) => {
1174
- const def = optionDefs.find((o) => {
1175
- return o.name === key;
1176
- });
1177
- if (!def) {
1178
- return `Unknown option --${key}`;
1179
- }
1180
- if (def.choices && value !== void 0) {
1181
- if (
1182
- !(def.variadic ? value : [value]).every((v) => {
1183
- return def.choices.includes(v);
1184
- })
1185
- ) {
1186
- return `Invalid option value ${def.flags}: Got \`${value}\`. Accepted values: [${def.choices
1187
- .map((c) => {
1188
- return `\`${c}\``;
1189
- })
1190
- .join(',')}]`;
1191
- }
1192
- }
1193
- }),
1194
- )
1195
- .filter((s) => {
1196
- return s !== void 0;
1197
- })
1198
- .reduce(
1199
- (acc, curr) => {
1200
- return (acc ?? []).concat(curr);
1201
- },
1202
- void 0,
1203
- );
1086
+ }
1087
+ }).concat(entriesOf(optionValues).map(([key, value]) => {
1088
+ const def = optionDefs.find((o) => {
1089
+ return o.name === key;
1090
+ });
1091
+ if (!def) {
1092
+ return `Unknown option --${key}`;
1093
+ }
1094
+ if (def.choices && value !== void 0) {
1095
+ if (!(def.variadic ? value : [
1096
+ value
1097
+ ]).every((v) => {
1098
+ return def.choices.includes(v);
1099
+ })) {
1100
+ return `Invalid option value ${def.flags}: Got \`${value}\`. Accepted values: [${def.choices.map((c) => {
1101
+ return `\`${c}\``;
1102
+ }).join(",")}]`;
1103
+ }
1104
+ }
1105
+ })).filter((s) => {
1106
+ return s !== void 0;
1107
+ }).reduce((acc, curr) => {
1108
+ return (acc ?? []).concat(curr);
1109
+ }, void 0);
1204
1110
  }
1205
- __name(validateParsed, 'validateParsed');
1111
+ __name(validateParsed, "validateParsed");
1206
1112
 
1207
1113
  // src/lib/Command.ts
1208
1114
  function _ts_decorate2(decorators, target, key, desc) {
1209
- var c = arguments.length,
1210
- r = c < 3 ? target : desc === null ? (desc = Object.getOwnPropertyDescriptor(target, key)) : desc,
1211
- d;
1212
- if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') {
1213
- r = Reflect.decorate(decorators, target, key, desc);
1214
- } else {
1215
- for (var i = decorators.length - 1; i >= 0; i--) {
1216
- if ((d = decorators[i])) {
1217
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1218
- }
1219
- }
1220
- }
1221
- return (c > 3 && r && Object.defineProperty(target, key, r), r);
1115
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1116
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1117
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1118
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1222
1119
  }
1223
- __name(_ts_decorate2, '_ts_decorate');
1120
+ __name(_ts_decorate2, "_ts_decorate");
1224
1121
  function _ts_metadata2(k, v) {
1225
- if (typeof Reflect === 'object' && typeof Reflect.metadata === 'function') {
1226
- return Reflect.metadata(k, v);
1227
- }
1122
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1228
1123
  }
1229
- __name(_ts_metadata2, '_ts_metadata');
1124
+ __name(_ts_metadata2, "_ts_metadata");
1230
1125
  var Command = class _Command {
1231
1126
  static {
1232
- __name(this, 'Command');
1127
+ __name(this, "Command");
1233
1128
  }
1234
1129
  /** parent command in the hierarchy, undefined for root command */
1235
1130
  parent;
@@ -1260,35 +1155,31 @@ var Command = class _Command {
1260
1155
  constructor(name, parent) {
1261
1156
  this.name = name;
1262
1157
  this.aliases = [];
1263
- this.description = '';
1158
+ this.description = "";
1264
1159
  this.arguments = [];
1265
1160
  this.options = [];
1266
1161
  this.commands = {};
1267
1162
  this.hooks = [];
1268
- Object.defineProperty(this, 'parent', {
1163
+ Object.defineProperty(this, "parent", {
1269
1164
  value: parent,
1270
- enumerable: false,
1165
+ enumerable: false
1271
1166
  });
1272
1167
  if (!parent) {
1273
- this.addOption('-D, --debug', {
1274
- description: 'Display debug information',
1275
- }).addOptionHook('debug', ({ cmd, ...data }) => {
1276
- console.debug(
1277
- inspect(cmd, {
1278
- depth: 1,
1279
- colors: true,
1280
- }),
1281
- );
1282
- console.debug(
1283
- inspect(data, {
1284
- depth: 3,
1285
- colors: true,
1286
- }),
1287
- );
1168
+ this.addOption("-D, --debug", {
1169
+ description: "Display debug information"
1170
+ }).addOptionHook("debug", ({ cmd, ...data }) => {
1171
+ console.debug(inspect(cmd, {
1172
+ depth: 1,
1173
+ colors: true
1174
+ }));
1175
+ console.debug(inspect(data, {
1176
+ depth: 3,
1177
+ colors: true
1178
+ }));
1288
1179
  });
1289
- this.addOption('-h, --help', {
1290
- description: 'Display help information',
1291
- }).addOptionHook('help', ({ cmd }) => {
1180
+ this.addOption("-h, --help", {
1181
+ description: "Display help information"
1182
+ }).addOptionHook("help", ({ cmd }) => {
1292
1183
  console.log(cmd.renderHelp());
1293
1184
  process.exitCode = 0;
1294
1185
  });
@@ -1320,23 +1211,20 @@ var Command = class _Command {
1320
1211
  }
1321
1212
  /** adds aliases to existing ones */
1322
1213
  addAliases(...aliases) {
1323
- const taken = this.parent
1324
- ? valuesOf(this.parent.commands).flatMap((c) => {
1325
- return [c.name, ...c.aliases];
1326
- })
1327
- : [];
1328
- arrRemoveDuplicates(aliases.flat())
1329
- .filter((a) => {
1330
- return !this.aliases.includes(a) && a !== this.name;
1331
- })
1332
- .forEach((a) => {
1333
- if (taken.includes(a)) {
1334
- throw new Error(
1335
- `Alias "${a}" is already used by a sibling command: ${findCommand(this.parent, a)?.name}`,
1336
- );
1337
- }
1338
- this.aliases.push(a);
1339
- });
1214
+ const taken = this.parent ? valuesOf(this.parent.commands).flatMap((c) => {
1215
+ return [
1216
+ c.name,
1217
+ ...c.aliases
1218
+ ];
1219
+ }) : [];
1220
+ arrRemoveDuplicates(aliases.flat()).filter((a) => {
1221
+ return !this.aliases.includes(a) && a !== this.name;
1222
+ }).forEach((a) => {
1223
+ if (taken.includes(a)) {
1224
+ throw new Error(`Alias "${a}" is already used by a sibling command: ${findCommand(this.parent, a)?.name}`);
1225
+ }
1226
+ this.aliases.push(a);
1227
+ });
1340
1228
  this.aliases.sort((a, b) => {
1341
1229
  return a.length - b.length;
1342
1230
  });
@@ -1345,17 +1233,15 @@ var Command = class _Command {
1345
1233
  /** sets the command version */
1346
1234
  setVersion(version) {
1347
1235
  this.version = version;
1348
- if (findOption(this, 'version')) {
1236
+ if (findOption(this, "version")) {
1349
1237
  return this;
1350
1238
  }
1351
- return this.addOption('-V, --version', {
1352
- description: 'Display semver version',
1353
- }).addOptionHook('version', ({ cmd }) => {
1354
- console.log(
1355
- getCommandAndAncestors(cmd).find((c) => {
1356
- return c.version;
1357
- })?.version,
1358
- );
1239
+ return this.addOption("-V, --version", {
1240
+ description: "Display semver version"
1241
+ }).addOptionHook("version", ({ cmd }) => {
1242
+ console.log(getCommandAndAncestors(cmd).find((c) => {
1243
+ return c.version;
1244
+ })?.version);
1359
1245
  process.exitCode = 0;
1360
1246
  });
1361
1247
  }
@@ -1366,7 +1252,7 @@ var Command = class _Command {
1366
1252
  }
1367
1253
  /** sets command description, joining variadic lines */
1368
1254
  setDescription(...lines) {
1369
- this.description = lines.join('\n');
1255
+ this.description = lines.join("\n");
1370
1256
  return this;
1371
1257
  }
1372
1258
  /** sets whether command is hidden from help */
@@ -1380,12 +1266,10 @@ var Command = class _Command {
1380
1266
  return this;
1381
1267
  }
1382
1268
  /** add a subcommand and return the subcommand. All options are inherited by the subcommand. */
1383
-
1269
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1384
1270
  command(name, cb) {
1385
1271
  if (this.arguments.length) {
1386
- throw new Error(
1387
- `Cannot add subcommand "${name}" to "${this.name}" because it already has arguments defined.`,
1388
- );
1272
+ throw new Error(`Cannot add subcommand "${name}" to "${this.name}" because it already has arguments defined.`);
1389
1273
  }
1390
1274
  const sub = this.createSubcommand(name);
1391
1275
  const inherit = this.options;
@@ -1397,30 +1281,27 @@ var Command = class _Command {
1397
1281
  });
1398
1282
  sub.hooks.push(...inheritHooks);
1399
1283
  const taken = valuesOf(this.commands).flatMap((c) => {
1400
- return [c.name, ...c.aliases];
1284
+ return [
1285
+ c.name,
1286
+ ...c.aliases
1287
+ ];
1401
1288
  });
1402
1289
  if (taken.includes(name)) {
1403
- throw new Error(
1404
- `Command name "${getCommandAndAncestors(sub).map((c) => {
1405
- return c.name;
1406
- })}" is already used by this command or its aliases: ${taken.join(', ')}`,
1407
- );
1290
+ throw new Error(`Command name "${getCommandAndAncestors(sub).map((c) => {
1291
+ return c.name;
1292
+ })}" is already used by this command or its aliases: ${taken.join(", ")}`);
1408
1293
  }
1409
1294
  const kebab = kebabCase(name);
1410
- const words = kebab.split('-');
1411
- const initials = words
1412
- .map((s) => {
1413
- return s[0];
1414
- })
1415
- .join('');
1295
+ const words = kebab.split("-");
1296
+ const initials = words.map((s) => {
1297
+ return s[0];
1298
+ }).join("");
1416
1299
  if (!taken.includes(initials)) {
1417
1300
  sub.addAliases(initials);
1418
1301
  } else {
1419
- const initials2 = words
1420
- .map((s) => {
1421
- return s[0] + s[1];
1422
- })
1423
- .join('');
1302
+ const initials2 = words.map((s) => {
1303
+ return s[0] + s[1];
1304
+ }).join("");
1424
1305
  if (!taken.includes(initials2)) {
1425
1306
  sub.addAliases(initials2);
1426
1307
  }
@@ -1429,7 +1310,7 @@ var Command = class _Command {
1429
1310
  return cb ? cb(sub, this) : sub;
1430
1311
  }
1431
1312
  /** add a subcommand and return the subcommand. All options are inherited by the subcommand. */
1432
-
1313
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1433
1314
  addCommand(name, cb) {
1434
1315
  this.command(name, cb);
1435
1316
  return this;
@@ -1439,9 +1320,9 @@ var Command = class _Command {
1439
1320
  if (!/^<(.*?)>$|^\[(.*?)\]$/.test(usage)) {
1440
1321
  throw new Error(`Invalid argument format: ${usage}`);
1441
1322
  }
1442
- const name = usage.slice(1, -1).replace(/\.\.\.$/, '');
1443
- const required = usage.startsWith('<');
1444
- const variadic = usage.slice(0, -1).endsWith('...');
1323
+ const name = usage.slice(1, -1).replace(/\.\.\.$/, "");
1324
+ const required = usage.startsWith("<");
1325
+ const variadic = usage.slice(0, -1).endsWith("...");
1445
1326
  const prevArg = this.arguments[this.arguments.length - 1];
1446
1327
  if (prevArg?.variadic) {
1447
1328
  throw new Error(`Cannot add argument ${usage} after variadic argument ${prevArg.usage}`);
@@ -1450,16 +1331,14 @@ var Command = class _Command {
1450
1331
  throw new Error(`Cannot add required argument ${usage} after optional argument ${prevArg?.usage}`);
1451
1332
  }
1452
1333
  if (required && prevArg?.defaultValue) {
1453
- throw new Error(
1454
- `Cannot add required argument ${usage} after optional argument with default value ${prevArg.usage}`,
1455
- );
1334
+ throw new Error(`Cannot add required argument ${usage} after optional argument with default value ${prevArg.usage}`);
1456
1335
  }
1457
1336
  const arg = {
1458
1337
  usage,
1459
1338
  name,
1460
1339
  required,
1461
1340
  variadic,
1462
- ...options,
1341
+ ...options
1463
1342
  };
1464
1343
  if (variadic && !arg.defaultValue) {
1465
1344
  arg.defaultValue = [];
@@ -1468,8 +1347,8 @@ var Command = class _Command {
1468
1347
  return this;
1469
1348
  }
1470
1349
  /**
1471
- * adds command-line option with type inference. Parses format: `-s, --long [<value>|[value]|<value...>|[value...]]`
1472
- */
1350
+ * adds command-line option with type inference. Parses format: `-s, --long [<value>|[value]|<value...>|[value...]]`
1351
+ */
1473
1352
  addOption(flags, opts = {}) {
1474
1353
  const ins = {};
1475
1354
  const { short, long, name, argName } = parseOptionFlags(flags);
@@ -1485,21 +1364,21 @@ var Command = class _Command {
1485
1364
  ins.short = short;
1486
1365
  ins.long = long;
1487
1366
  ins.name = name;
1488
- ins.description = '';
1367
+ ins.description = "";
1489
1368
  if (!argName) {
1490
- ins.type = 'boolean';
1369
+ ins.type = "boolean";
1491
1370
  } else {
1492
- ins.type = 'string';
1371
+ ins.type = "string";
1493
1372
  ins.argName = argName;
1494
- if (flags.endsWith('>')) {
1495
- if (flags.endsWith('...>')) {
1373
+ if (flags.endsWith(">")) {
1374
+ if (flags.endsWith("...>")) {
1496
1375
  ins.required = true;
1497
1376
  ins.variadic = true;
1498
1377
  } else {
1499
1378
  ins.required = true;
1500
1379
  }
1501
- } else if (flags.endsWith(']')) {
1502
- if (flags.endsWith('...]')) {
1380
+ } else if (flags.endsWith("]")) {
1381
+ if (flags.endsWith("...]")) {
1503
1382
  ins.variadic = true;
1504
1383
  ins.defaultValue = opts.defaultValue ?? [];
1505
1384
  }
@@ -1510,18 +1389,15 @@ var Command = class _Command {
1510
1389
  Reflect.set(ins, key, value);
1511
1390
  }
1512
1391
  }
1513
- if (ins.env && ins.defaultValue === void 0 && typeof process.env[ins.env] === 'string') {
1392
+ if (ins.env && ins.defaultValue === void 0 && typeof process.env[ins.env] === "string") {
1514
1393
  ins.required = false;
1515
- ins.flags = ins.flags.replace('<', '[').replace('>', ']');
1516
- if (ins.type === 'boolean') {
1394
+ ins.flags = ins.flags.replace("<", "[").replace(">", "]");
1395
+ if (ins.type === "boolean") {
1517
1396
  ins.defaultValue = /^(t(rue)?|y(es)?|1)$/i.test(process.env[ins.env]);
1518
1397
  } else if (ins.variadic) {
1519
- ins.defaultValue = process.env[ins.env]
1520
- .replace(/\]|\[/, '')
1521
- .split(',')
1522
- .map((v) => {
1523
- return v.trim();
1524
- });
1398
+ ins.defaultValue = process.env[ins.env].replace(/\]|\[/, "").split(",").map((v) => {
1399
+ return v.trim();
1400
+ });
1525
1401
  } else {
1526
1402
  ins.defaultValue = process.env[ins.env];
1527
1403
  }
@@ -1530,27 +1406,23 @@ var Command = class _Command {
1530
1406
  return this;
1531
1407
  }
1532
1408
  /**
1533
- * register an action to be invoked when an option is set to true or string value.
1534
- *
1535
- * Hooks execute in addition to or instead of the main action handler,
1536
- * allowing for option-driven behavior. For example, `--help` and `--version`
1537
- * are implemented as hooks.
1538
- */
1409
+ * register an action to be invoked when an option is set to true or string value.
1410
+ *
1411
+ * Hooks execute in addition to or instead of the main action handler,
1412
+ * allowing for option-driven behavior. For example, `--help` and `--version`
1413
+ * are implemented as hooks.
1414
+ */
1539
1415
  addOptionHook(optionName, action) {
1540
1416
  const def = findOption(this, optionName);
1541
1417
  if (!def.group && /process\.exitCode ?= ?.+;?\s*\}$/.test(action.toString())) {
1542
- def.group = 'Command Options';
1418
+ def.group = "Command Options";
1543
1419
  }
1544
1420
  this.hooks.push({
1545
1421
  name: optionName,
1546
1422
  predicate: setName(`has${strFirstCharToUpperCase(optionName)}`, ({ opts }) => {
1547
- return (
1548
- opts[optionName] !== void 0 &&
1549
- opts[optionName] !== false &&
1550
- !(Array.isArray(opts[optionName]) && opts[optionName].length === 0)
1551
- );
1423
+ return opts[optionName] !== void 0 && opts[optionName] !== false && !(Array.isArray(opts[optionName]) && opts[optionName].length === 0);
1552
1424
  }),
1553
- action: setName(optionName, action),
1425
+ action: setName(optionName, action)
1554
1426
  });
1555
1427
  return this;
1556
1428
  }
@@ -1563,23 +1435,21 @@ var Command = class _Command {
1563
1435
  argv = normalizeArgv(argv, this.options);
1564
1436
  const parsed = parseArgs({
1565
1437
  args: argv,
1566
- options: Object.fromEntries(
1567
- this.options.map((o) => {
1568
- return [
1569
- o.name,
1570
- {
1571
- type: o.type,
1572
- short: o.short,
1573
- default: o.defaultValue,
1574
- multiple: !!o.variadic,
1575
- },
1576
- ];
1577
- }),
1578
- ),
1438
+ options: Object.fromEntries(this.options.map((o) => {
1439
+ return [
1440
+ o.name,
1441
+ {
1442
+ type: o.type,
1443
+ short: o.short,
1444
+ default: o.defaultValue,
1445
+ multiple: !!o.variadic
1446
+ }
1447
+ ];
1448
+ })),
1579
1449
  allowPositionals: true,
1580
1450
  tokens: true,
1581
1451
  strict: false,
1582
- allowNegative: true,
1452
+ allowNegative: true
1583
1453
  });
1584
1454
  collectVariadicOptionValues(parsed, this.options);
1585
1455
  mergeOptionDefaults(parsed.values, this.options);
@@ -1601,7 +1471,7 @@ var Command = class _Command {
1601
1471
  args,
1602
1472
  opts,
1603
1473
  errors,
1604
- cmd: this,
1474
+ cmd: this
1605
1475
  };
1606
1476
  const hooks = this.hooks.filter((t) => {
1607
1477
  return t.predicate(data);
@@ -1613,7 +1483,13 @@ var Command = class _Command {
1613
1483
  return;
1614
1484
  }
1615
1485
  }
1616
- await timer([[...path, this.name].join(' '), this.description], async (logger) => {
1486
+ await timer([
1487
+ [
1488
+ ...path,
1489
+ this.name
1490
+ ].join(" "),
1491
+ this.description
1492
+ ], async (logger) => {
1617
1493
  if (errors) {
1618
1494
  errors.forEach((msg) => {
1619
1495
  return logger.error(C.red(msg));
@@ -1627,22 +1503,22 @@ var Command = class _Command {
1627
1503
  args,
1628
1504
  opts,
1629
1505
  cmd: this,
1630
- logger,
1506
+ logger
1631
1507
  });
1632
1508
  }
1633
1509
  console.log(this.renderHelp());
1634
1510
  });
1635
- }, 'execute');
1511
+ }, "execute");
1636
1512
  return {
1637
1513
  ...data,
1638
1514
  hooks,
1639
- execute,
1515
+ execute
1640
1516
  };
1641
1517
  }
1642
1518
  /**
1643
- * sets the main action handler for this command, which is executed after any matching option hooks when the command is invoked.
1644
- * The handler receives parsed arguments and options with correct typings.
1645
- */
1519
+ * sets the main action handler for this command, which is executed after any matching option hooks when the command is invoked.
1520
+ * The handler receives parsed arguments and options with correct typings.
1521
+ */
1646
1522
  setAction(fn) {
1647
1523
  this.action = setName(this.name, fn);
1648
1524
  return this;
@@ -1652,15 +1528,10 @@ var Command = class _Command {
1652
1528
  return new _Command(name, this);
1653
1529
  }
1654
1530
  };
1655
- _ts_decorate2(
1656
- [
1657
- lazyProp,
1658
- _ts_metadata2('design:type', typeof Help === 'undefined' ? Object : Help),
1659
- _ts_metadata2('design:paramtypes', []),
1660
- ],
1661
- Command.prototype,
1662
- 'help',
1663
- null,
1664
- );
1531
+ _ts_decorate2([
1532
+ lazyProp,
1533
+ _ts_metadata2("design:type", typeof Help === "undefined" ? Object : Help),
1534
+ _ts_metadata2("design:paramtypes", [])
1535
+ ], Command.prototype, "help", null);
1665
1536
 
1666
1537
  export { Command, Help, findCommand, findOption, getCommandAncestors, getCommandAndAncestors, parseOptionFlags };