@optique/core 1.4.0-dev.2676 → 1.4.0-dev.2679

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/dist/doc.cjs CHANGED
@@ -141,7 +141,8 @@ function cloneDocEntry(entry) {
141
141
  ...entry.envVars != null && { envVars: [...entry.envVars] },
142
142
  ...entry.description != null && { description: require_message.cloneMessage(entry.description) },
143
143
  ...entry.default != null && { default: require_message.cloneMessage(entry.default) },
144
- ...entry.choices != null && { choices: require_message.cloneMessage(entry.choices) }
144
+ ...entry.choices != null && { choices: require_message.cloneMessage(entry.choices) },
145
+ ...entry.showAliases != null && { showAliases: entry.showAliases }
145
146
  };
146
147
  }
147
148
  /**
@@ -310,6 +311,14 @@ function formatDocPage(programName, page, options = {}) {
310
311
  const choicesAmbient = options.theme?.annotationStyles?.choices ?? { dim: true };
311
312
  const environmentAmbient = options.theme?.annotationStyles?.environment ?? { dim: true };
312
313
  const environmentStyle = require_terminal_internal.styleCode(environmentAmbient);
314
+ const aliasesAmbient = options.theme?.annotationStyles?.aliases ?? { dim: true };
315
+ const aliasesStyle = require_terminal_internal.styleCode(aliasesAmbient);
316
+ const showAliasesByDefault = options.showAliases != null && options.showAliases !== false;
317
+ const aliasesContent = (entry) => {
318
+ if (entry.term.type !== "command") return [];
319
+ if (!(entry.showAliases ?? showAliasesByDefault)) return [];
320
+ return (entry.term.aliases ?? []).filter((alias) => alias !== "").flatMap((alias, i) => i === 0 ? [require_message.text(alias)] : [require_message.text(", "), require_message.text(alias)]);
321
+ };
313
322
  const environmentPlacement = typeof options.showEnvironment === "object" ? options.showEnvironment.placement ?? "inline" : options.showEnvironment ? "inline" : void 0;
314
323
  const showInlineEnvironment = environmentPlacement === "inline" || environmentPlacement === "both";
315
324
  const environmentContent = (entry) => [...new Set(entry.envVars ?? [])].filter((name) => name !== "").flatMap((name, i) => i === 0 ? [require_message.envVar(name)] : [require_message.text(", "), require_message.envVar(name)]);
@@ -322,7 +331,7 @@ function formatDocPage(programName, page, options = {}) {
322
331
  type: "label",
323
332
  label: label$1,
324
333
  kind
325
- }, options.theme, options.colors, void 0, kind === "choices" ? choicesAmbient : void 0);
334
+ }, options.theme, options.colors, void 0, kind === "choices" ? choicesAmbient : kind === "aliases" ? aliasesAmbient : void 0);
326
335
  labelCache.set(key, rendered);
327
336
  }
328
337
  return rendered;
@@ -336,7 +345,7 @@ function formatDocPage(programName, page, options = {}) {
336
345
  type: "syntaxPunctuation",
337
346
  punctuation: punctuation$1,
338
347
  kind
339
- }, options.theme, options.colors, void 0, kind.startsWith("default") ? defaultAmbient : kind.startsWith("choices") ? choicesAmbient : void 0);
348
+ }, options.theme, options.colors, void 0, kind.startsWith("default") ? defaultAmbient : kind.startsWith("choices") ? choicesAmbient : kind.startsWith("aliases") ? aliasesAmbient : void 0);
340
349
  punctuationCache.set(key, rendered);
341
350
  }
342
351
  return rendered;
@@ -372,7 +381,7 @@ function formatDocPage(programName, page, options = {}) {
372
381
  if (maxItems < 1) throw new RangeError(`showChoices.maxItems must be at least 1, but got ${maxItems}.`);
373
382
  }
374
383
  const hasContent = (msg) => Array.isArray(msg) && msg.length > 0;
375
- const needsDescriptionColumn = (entry) => hasContent(entry.description) || (options.showDefault === true || typeof options.showDefault === "object") && hasContent(entry.default) || (options.showChoices === true || typeof options.showChoices === "object") && hasContent(entry.choices) || showInlineEnvironment && hasContent(environmentContent(entry));
384
+ const needsDescriptionColumn = (entry) => hasContent(entry.description) || (options.showDefault === true || typeof options.showDefault === "object") && hasContent(entry.default) || (options.showChoices === true || typeof options.showChoices === "object") && hasContent(entry.choices) || showInlineEnvironment && hasContent(environmentContent(entry)) || hasContent(aliasesContent(entry));
376
385
  const annotations = /* @__PURE__ */ new Map();
377
386
  const annotation = (kind) => {
378
387
  const cached = annotations.get(kind);
@@ -382,6 +391,12 @@ function formatDocPage(programName, page, options = {}) {
382
391
  annotations.set(kind, layout$1);
383
392
  return layout$1;
384
393
  }
394
+ if (kind === "aliases") {
395
+ const config$1 = typeof options.showAliases === "object" ? options.showAliases : {};
396
+ const layout$1 = require_text_layout.measureAnnotation(punctuation(config$1.prefix ?? " (", "aliasesPrefix") + label(config$1.label ?? "aliases: ", "aliases"), punctuation(config$1.suffix ?? ")", "aliasesSuffix"));
397
+ annotations.set(kind, layout$1);
398
+ return layout$1;
399
+ }
385
400
  const config = kind === "default" ? options.showDefault : options.showChoices;
386
401
  const prefix = punctuation(typeof config === "object" ? config.prefix ?? (kind === "default" ? " [" : " (") : kind === "default" ? " [" : " (", kind === "default" ? "defaultPrefix" : "choicesPrefix");
387
402
  const suffix = punctuation(typeof config === "object" ? config.suffix ?? (kind === "default" ? "]" : ")") : kind === "default" ? "]" : ")", kind === "default" ? "defaultSuffix" : "choicesSuffix");
@@ -420,10 +435,11 @@ function formatDocPage(programName, page, options = {}) {
420
435
  if (needsDescColumn) for (const kind of [
421
436
  "default",
422
437
  "choices",
423
- "environment"
438
+ "environment",
439
+ "aliases"
424
440
  ]) {
425
- const enabled = kind === "default" ? options.showDefault : kind === "choices" ? options.showChoices : showInlineEnvironment;
426
- if (enabled && page.sections.some((section) => section.entries.some((entry) => hasContent(kind === "environment" ? environmentContent(entry) : entry[kind])))) minDescWidth = Math.max(minDescWidth, annotation(kind).minWidth);
441
+ const enabled = kind === "default" ? options.showDefault : kind === "choices" ? options.showChoices : kind === "environment" ? showInlineEnvironment : true;
442
+ if (enabled && page.sections.some((section) => section.entries.some((entry) => hasContent(kind === "environment" ? environmentContent(entry) : kind === "aliases" ? aliasesContent(entry) : entry[kind])))) minDescWidth = Math.max(minDescWidth, annotation(kind).minWidth);
427
443
  }
428
444
  const splitEntryMin = termIndent + 2 + Math.max(2, 2 * minDescWidth - 1);
429
445
  const fixedEntryMin = termIndent + 2 + termWidth + minDescWidth;
@@ -550,6 +566,8 @@ function formatDocPage(programName, page, options = {}) {
550
566
  description += options.colors ? `${style}${annotationText}${style ? "\x1B[0m" : ""}` : annotationText;
551
567
  cursor = suffix.cursor;
552
568
  };
569
+ const aliases = aliasesContent(entry);
570
+ if (hasContent(aliases)) appendAnnotation(aliases, annotation("aliases"), aliasesStyle, aliasesAmbient, false);
553
571
  if (options.showDefault && hasContent(entry.default)) appendAnnotation(entry.default, annotation("default"), defaultStyle, defaultAmbient, !options.colors);
554
572
  if (options.showChoices && hasContent(entry.choices)) {
555
573
  const maxItems = typeof options.showChoices === "object" ? options.showChoices.maxItems ?? 8 : 8;
package/dist/doc.d.cts CHANGED
@@ -41,6 +41,15 @@ interface DocEntry {
41
41
  * @since 1.4.0
42
42
  */
43
43
  readonly envVars?: readonly string[];
44
+ /**
45
+ * Per-entry override for showing the aliases of a command term. When
46
+ * `true`, the term's `aliases` are shown even if the formatter's
47
+ * `showAliases` option is off; when `false`, they are hidden even if it is
48
+ * on. When omitted, the formatter's `showAliases` option decides.
49
+ * Ignored for entries whose term is not a command.
50
+ * @since 1.4.0
51
+ */
52
+ readonly showAliases?: boolean;
44
53
  }
45
54
  /**
46
55
  * A section in a document that groups related entries together.
@@ -261,6 +270,28 @@ interface ShowChoicesOptions {
261
270
  */
262
271
  readonly maxItems?: number;
263
272
  }
273
+ /**
274
+ * Configuration for customizing how command aliases are displayed in help
275
+ * output.
276
+ * @since 1.4.0
277
+ */
278
+ interface ShowAliasesOptions {
279
+ /**
280
+ * Text to display before the alias list.
281
+ * @default `" ("`
282
+ */
283
+ readonly prefix?: string;
284
+ /**
285
+ * Text to display after the alias list.
286
+ * @default `")"`
287
+ */
288
+ readonly suffix?: string;
289
+ /**
290
+ * Label text to display before the individual aliases.
291
+ * @default `"aliases: "`
292
+ */
293
+ readonly label?: string;
294
+ }
264
295
  /**
265
296
  * Options for formatting a documentation page.
266
297
  */
@@ -365,6 +396,31 @@ interface DocPageFormatOptions {
365
396
  * ```
366
397
  */
367
398
  showChoices?: boolean | ShowChoicesOptions;
399
+ /**
400
+ * Whether and how to display the aliases of commands in command lists.
401
+ *
402
+ * - `boolean`: When `true`, displays aliases using format
403
+ * `(aliases: i, add)`
404
+ * - `ShowAliasesOptions`: Custom formatting with configurable prefix,
405
+ * suffix, and label
406
+ *
407
+ * This is the fallback for entries that do not set
408
+ * {@link DocEntry.showAliases}; an entry's own setting always wins.
409
+ * Aliases are automatically dimmed when `colors` is enabled.
410
+ *
411
+ * @default `false`
412
+ * @since 1.4.0
413
+ *
414
+ * @example
415
+ * ```typescript
416
+ * // Basic usage - shows "(aliases: i, add)"
417
+ * { showAliases: true }
418
+ *
419
+ * // Custom format - shows "[aka i, add]"
420
+ * { showAliases: { prefix: " [", suffix: "]", label: "aka " } }
421
+ * ```
422
+ */
423
+ showAliases?: boolean | ShowAliasesOptions;
368
424
  /**
369
425
  * A custom comparator function to control the order of sections in the
370
426
  * help output. When provided, it is used instead of the default smart
@@ -429,4 +485,4 @@ interface DocPageFormatOptions {
429
485
  */
430
486
  declare function formatDocPage(programName: string, page: DocPage, options?: DocPageFormatOptions): string;
431
487
  //#endregion
432
- export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, EnvironmentBindingDoc, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden };
488
+ export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, EnvironmentBindingDoc, ShowAliasesOptions, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden };
package/dist/doc.d.ts CHANGED
@@ -41,6 +41,15 @@ interface DocEntry {
41
41
  * @since 1.4.0
42
42
  */
43
43
  readonly envVars?: readonly string[];
44
+ /**
45
+ * Per-entry override for showing the aliases of a command term. When
46
+ * `true`, the term's `aliases` are shown even if the formatter's
47
+ * `showAliases` option is off; when `false`, they are hidden even if it is
48
+ * on. When omitted, the formatter's `showAliases` option decides.
49
+ * Ignored for entries whose term is not a command.
50
+ * @since 1.4.0
51
+ */
52
+ readonly showAliases?: boolean;
44
53
  }
45
54
  /**
46
55
  * A section in a document that groups related entries together.
@@ -261,6 +270,28 @@ interface ShowChoicesOptions {
261
270
  */
262
271
  readonly maxItems?: number;
263
272
  }
273
+ /**
274
+ * Configuration for customizing how command aliases are displayed in help
275
+ * output.
276
+ * @since 1.4.0
277
+ */
278
+ interface ShowAliasesOptions {
279
+ /**
280
+ * Text to display before the alias list.
281
+ * @default `" ("`
282
+ */
283
+ readonly prefix?: string;
284
+ /**
285
+ * Text to display after the alias list.
286
+ * @default `")"`
287
+ */
288
+ readonly suffix?: string;
289
+ /**
290
+ * Label text to display before the individual aliases.
291
+ * @default `"aliases: "`
292
+ */
293
+ readonly label?: string;
294
+ }
264
295
  /**
265
296
  * Options for formatting a documentation page.
266
297
  */
@@ -365,6 +396,31 @@ interface DocPageFormatOptions {
365
396
  * ```
366
397
  */
367
398
  showChoices?: boolean | ShowChoicesOptions;
399
+ /**
400
+ * Whether and how to display the aliases of commands in command lists.
401
+ *
402
+ * - `boolean`: When `true`, displays aliases using format
403
+ * `(aliases: i, add)`
404
+ * - `ShowAliasesOptions`: Custom formatting with configurable prefix,
405
+ * suffix, and label
406
+ *
407
+ * This is the fallback for entries that do not set
408
+ * {@link DocEntry.showAliases}; an entry's own setting always wins.
409
+ * Aliases are automatically dimmed when `colors` is enabled.
410
+ *
411
+ * @default `false`
412
+ * @since 1.4.0
413
+ *
414
+ * @example
415
+ * ```typescript
416
+ * // Basic usage - shows "(aliases: i, add)"
417
+ * { showAliases: true }
418
+ *
419
+ * // Custom format - shows "[aka i, add]"
420
+ * { showAliases: { prefix: " [", suffix: "]", label: "aka " } }
421
+ * ```
422
+ */
423
+ showAliases?: boolean | ShowAliasesOptions;
368
424
  /**
369
425
  * A custom comparator function to control the order of sections in the
370
426
  * help output. When provided, it is used instead of the default smart
@@ -429,4 +485,4 @@ interface DocPageFormatOptions {
429
485
  */
430
486
  declare function formatDocPage(programName: string, page: DocPage, options?: DocPageFormatOptions): string;
431
487
  //#endregion
432
- export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, EnvironmentBindingDoc, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden };
488
+ export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, EnvironmentBindingDoc, ShowAliasesOptions, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden };
package/dist/doc.js CHANGED
@@ -141,7 +141,8 @@ function cloneDocEntry(entry) {
141
141
  ...entry.envVars != null && { envVars: [...entry.envVars] },
142
142
  ...entry.description != null && { description: cloneMessage(entry.description) },
143
143
  ...entry.default != null && { default: cloneMessage(entry.default) },
144
- ...entry.choices != null && { choices: cloneMessage(entry.choices) }
144
+ ...entry.choices != null && { choices: cloneMessage(entry.choices) },
145
+ ...entry.showAliases != null && { showAliases: entry.showAliases }
145
146
  };
146
147
  }
147
148
  /**
@@ -310,6 +311,14 @@ function formatDocPage(programName, page, options = {}) {
310
311
  const choicesAmbient = options.theme?.annotationStyles?.choices ?? { dim: true };
311
312
  const environmentAmbient = options.theme?.annotationStyles?.environment ?? { dim: true };
312
313
  const environmentStyle = styleCode(environmentAmbient);
314
+ const aliasesAmbient = options.theme?.annotationStyles?.aliases ?? { dim: true };
315
+ const aliasesStyle = styleCode(aliasesAmbient);
316
+ const showAliasesByDefault = options.showAliases != null && options.showAliases !== false;
317
+ const aliasesContent = (entry) => {
318
+ if (entry.term.type !== "command") return [];
319
+ if (!(entry.showAliases ?? showAliasesByDefault)) return [];
320
+ return (entry.term.aliases ?? []).filter((alias) => alias !== "").flatMap((alias, i) => i === 0 ? [text(alias)] : [text(", "), text(alias)]);
321
+ };
313
322
  const environmentPlacement = typeof options.showEnvironment === "object" ? options.showEnvironment.placement ?? "inline" : options.showEnvironment ? "inline" : void 0;
314
323
  const showInlineEnvironment = environmentPlacement === "inline" || environmentPlacement === "both";
315
324
  const environmentContent = (entry) => [...new Set(entry.envVars ?? [])].filter((name) => name !== "").flatMap((name, i) => i === 0 ? [envVar(name)] : [text(", "), envVar(name)]);
@@ -322,7 +331,7 @@ function formatDocPage(programName, page, options = {}) {
322
331
  type: "label",
323
332
  label: label$1,
324
333
  kind
325
- }, options.theme, options.colors, void 0, kind === "choices" ? choicesAmbient : void 0);
334
+ }, options.theme, options.colors, void 0, kind === "choices" ? choicesAmbient : kind === "aliases" ? aliasesAmbient : void 0);
326
335
  labelCache.set(key, rendered);
327
336
  }
328
337
  return rendered;
@@ -336,7 +345,7 @@ function formatDocPage(programName, page, options = {}) {
336
345
  type: "syntaxPunctuation",
337
346
  punctuation: punctuation$1,
338
347
  kind
339
- }, options.theme, options.colors, void 0, kind.startsWith("default") ? defaultAmbient : kind.startsWith("choices") ? choicesAmbient : void 0);
348
+ }, options.theme, options.colors, void 0, kind.startsWith("default") ? defaultAmbient : kind.startsWith("choices") ? choicesAmbient : kind.startsWith("aliases") ? aliasesAmbient : void 0);
340
349
  punctuationCache.set(key, rendered);
341
350
  }
342
351
  return rendered;
@@ -372,7 +381,7 @@ function formatDocPage(programName, page, options = {}) {
372
381
  if (maxItems < 1) throw new RangeError(`showChoices.maxItems must be at least 1, but got ${maxItems}.`);
373
382
  }
374
383
  const hasContent = (msg) => Array.isArray(msg) && msg.length > 0;
375
- const needsDescriptionColumn = (entry) => hasContent(entry.description) || (options.showDefault === true || typeof options.showDefault === "object") && hasContent(entry.default) || (options.showChoices === true || typeof options.showChoices === "object") && hasContent(entry.choices) || showInlineEnvironment && hasContent(environmentContent(entry));
384
+ const needsDescriptionColumn = (entry) => hasContent(entry.description) || (options.showDefault === true || typeof options.showDefault === "object") && hasContent(entry.default) || (options.showChoices === true || typeof options.showChoices === "object") && hasContent(entry.choices) || showInlineEnvironment && hasContent(environmentContent(entry)) || hasContent(aliasesContent(entry));
376
385
  const annotations = /* @__PURE__ */ new Map();
377
386
  const annotation = (kind) => {
378
387
  const cached = annotations.get(kind);
@@ -382,6 +391,12 @@ function formatDocPage(programName, page, options = {}) {
382
391
  annotations.set(kind, layout$1);
383
392
  return layout$1;
384
393
  }
394
+ if (kind === "aliases") {
395
+ const config$1 = typeof options.showAliases === "object" ? options.showAliases : {};
396
+ const layout$1 = measureAnnotation(punctuation(config$1.prefix ?? " (", "aliasesPrefix") + label(config$1.label ?? "aliases: ", "aliases"), punctuation(config$1.suffix ?? ")", "aliasesSuffix"));
397
+ annotations.set(kind, layout$1);
398
+ return layout$1;
399
+ }
385
400
  const config = kind === "default" ? options.showDefault : options.showChoices;
386
401
  const prefix = punctuation(typeof config === "object" ? config.prefix ?? (kind === "default" ? " [" : " (") : kind === "default" ? " [" : " (", kind === "default" ? "defaultPrefix" : "choicesPrefix");
387
402
  const suffix = punctuation(typeof config === "object" ? config.suffix ?? (kind === "default" ? "]" : ")") : kind === "default" ? "]" : ")", kind === "default" ? "defaultSuffix" : "choicesSuffix");
@@ -420,10 +435,11 @@ function formatDocPage(programName, page, options = {}) {
420
435
  if (needsDescColumn) for (const kind of [
421
436
  "default",
422
437
  "choices",
423
- "environment"
438
+ "environment",
439
+ "aliases"
424
440
  ]) {
425
- const enabled = kind === "default" ? options.showDefault : kind === "choices" ? options.showChoices : showInlineEnvironment;
426
- if (enabled && page.sections.some((section) => section.entries.some((entry) => hasContent(kind === "environment" ? environmentContent(entry) : entry[kind])))) minDescWidth = Math.max(minDescWidth, annotation(kind).minWidth);
441
+ const enabled = kind === "default" ? options.showDefault : kind === "choices" ? options.showChoices : kind === "environment" ? showInlineEnvironment : true;
442
+ if (enabled && page.sections.some((section) => section.entries.some((entry) => hasContent(kind === "environment" ? environmentContent(entry) : kind === "aliases" ? aliasesContent(entry) : entry[kind])))) minDescWidth = Math.max(minDescWidth, annotation(kind).minWidth);
427
443
  }
428
444
  const splitEntryMin = termIndent + 2 + Math.max(2, 2 * minDescWidth - 1);
429
445
  const fixedEntryMin = termIndent + 2 + termWidth + minDescWidth;
@@ -550,6 +566,8 @@ function formatDocPage(programName, page, options = {}) {
550
566
  description += options.colors ? `${style}${annotationText}${style ? "\x1B[0m" : ""}` : annotationText;
551
567
  cursor = suffix.cursor;
552
568
  };
569
+ const aliases = aliasesContent(entry);
570
+ if (hasContent(aliases)) appendAnnotation(aliases, annotation("aliases"), aliasesStyle, aliasesAmbient, false);
553
571
  if (options.showDefault && hasContent(entry.default)) appendAnnotation(entry.default, annotation("default"), defaultStyle, defaultAmbient, !options.colors);
554
572
  if (options.showChoices && hasContent(entry.choices)) {
555
573
  const maxItems = typeof options.showChoices === "object" ? options.showChoices.maxItems ?? 8 : 8;
package/dist/facade.cjs CHANGED
@@ -818,7 +818,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
818
818
  options = optionsParam ?? {};
819
819
  }
820
820
  require_validate.validateProgramName(programName);
821
- const { colors, messageFormatter, theme: requestedTheme, maxWidth: requestedMaxWidth, termWidth, showDefault, showChoices, showEnvironment, sectionOrder, helpSections, showUsage, usageLine, commandList = "recursive", aboveError = "usage", onError = () => {
821
+ const { colors, messageFormatter, theme: requestedTheme, maxWidth: requestedMaxWidth, termWidth, showDefault, showChoices, showAliases, showEnvironment, sectionOrder, helpSections, showUsage, usageLine, commandList = "recursive", aboveError = "usage", onError = () => {
822
822
  throw new RunParserError("Failed to parse command line arguments.");
823
823
  }, stderr = console.error, stdout = console.log, brief, description, examples, author, bugs, footer } = options;
824
824
  let maxWidth = requestedMaxWidth;
@@ -1033,6 +1033,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
1033
1033
  termWidth,
1034
1034
  showDefault,
1035
1035
  showChoices,
1036
+ showAliases,
1036
1037
  showEnvironment,
1037
1038
  sectionOrder,
1038
1039
  showUsage
@@ -1111,6 +1112,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
1111
1112
  termWidth,
1112
1113
  showDefault,
1113
1114
  showChoices,
1115
+ showAliases,
1114
1116
  showEnvironment,
1115
1117
  sectionOrder,
1116
1118
  showUsage
@@ -1311,16 +1313,20 @@ function collapseTopLevelCommandEntries(entries) {
1311
1313
  const isTopLevel = entry.term.name === topLevelName;
1312
1314
  if (existingIndex == null) {
1313
1315
  commandIndexes.set(topLevelName, collapsed.length);
1314
- collapsed.push(isTopLevel ? entry : { term: {
1316
+ collapsed.push(isTopLevel ? entry : { term: omitCommandAliases({
1315
1317
  ...entry.term,
1316
1318
  name: topLevelName
1317
- } });
1319
+ }) });
1318
1320
  continue;
1319
1321
  }
1320
1322
  if (isTopLevel) collapsed[existingIndex] = entry;
1321
1323
  }
1322
1324
  return collapsed;
1323
1325
  }
1326
+ function omitCommandAliases(term) {
1327
+ const { aliases: _aliases,...rest } = term;
1328
+ return rest;
1329
+ }
1324
1330
  function getTopLevelCommandName(name) {
1325
1331
  return name.split(" ", 1)[0] ?? name;
1326
1332
  }
package/dist/facade.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Message, MessageFormatter } from "./message.cjs";
2
2
  import { TerminalTheme } from "./terminal.cjs";
3
3
  import { HiddenVisibility, OptionName, Usage } from "./usage.cjs";
4
- import { DocPage, DocSection, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions } from "./doc.cjs";
4
+ import { DocPage, DocSection, ShowAliasesOptions, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions } from "./doc.cjs";
5
5
  import { InferMode, InferValue, Mode, ModeValue, Parser } from "./internal/parser.cjs";
6
6
  import { ShellCompletion } from "./completion.cjs";
7
7
  import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./context.cjs";
@@ -148,6 +148,22 @@ interface RunOptions<THelp, TError> {
148
148
  * @since 0.10.0
149
149
  */
150
150
  readonly showChoices?: boolean | ShowChoicesOptions;
151
+ /**
152
+ * Whether and how to display command aliases in command lists of help
153
+ * output.
154
+ *
155
+ * - `boolean`: When `true`, displays aliases using format
156
+ * `(aliases: i, add)`
157
+ * - `ShowAliasesOptions`: Custom formatting with configurable prefix,
158
+ * suffix, and label
159
+ *
160
+ * This is the fallback for commands that do not set their own
161
+ * `showAliases` option. Usage lines always show canonical command names.
162
+ *
163
+ * @default `false`
164
+ * @since 1.4.0
165
+ */
166
+ readonly showAliases?: boolean | ShowAliasesOptions;
151
167
  /**
152
168
  * Displays declared environment bindings in help. `true` selects inline
153
169
  * annotations; an object can select a section or both. Names without visible
package/dist/facade.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Message, MessageFormatter } from "./message.js";
2
2
  import { TerminalTheme } from "./terminal.js";
3
3
  import { HiddenVisibility, OptionName, Usage } from "./usage.js";
4
- import { DocPage, DocSection, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions } from "./doc.js";
4
+ import { DocPage, DocSection, ShowAliasesOptions, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions } from "./doc.js";
5
5
  import { InferMode, InferValue, Mode, ModeValue, Parser } from "./internal/parser.js";
6
6
  import { ShellCompletion } from "./completion.js";
7
7
  import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./context.js";
@@ -148,6 +148,22 @@ interface RunOptions<THelp, TError> {
148
148
  * @since 0.10.0
149
149
  */
150
150
  readonly showChoices?: boolean | ShowChoicesOptions;
151
+ /**
152
+ * Whether and how to display command aliases in command lists of help
153
+ * output.
154
+ *
155
+ * - `boolean`: When `true`, displays aliases using format
156
+ * `(aliases: i, add)`
157
+ * - `ShowAliasesOptions`: Custom formatting with configurable prefix,
158
+ * suffix, and label
159
+ *
160
+ * This is the fallback for commands that do not set their own
161
+ * `showAliases` option. Usage lines always show canonical command names.
162
+ *
163
+ * @default `false`
164
+ * @since 1.4.0
165
+ */
166
+ readonly showAliases?: boolean | ShowAliasesOptions;
151
167
  /**
152
168
  * Displays declared environment bindings in help. `true` selects inline
153
169
  * annotations; an object can select a section or both. Names without visible
package/dist/facade.js CHANGED
@@ -818,7 +818,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
818
818
  options = optionsParam ?? {};
819
819
  }
820
820
  validateProgramName(programName);
821
- const { colors, messageFormatter, theme: requestedTheme, maxWidth: requestedMaxWidth, termWidth, showDefault, showChoices, showEnvironment, sectionOrder, helpSections, showUsage, usageLine, commandList = "recursive", aboveError = "usage", onError = () => {
821
+ const { colors, messageFormatter, theme: requestedTheme, maxWidth: requestedMaxWidth, termWidth, showDefault, showChoices, showAliases, showEnvironment, sectionOrder, helpSections, showUsage, usageLine, commandList = "recursive", aboveError = "usage", onError = () => {
822
822
  throw new RunParserError("Failed to parse command line arguments.");
823
823
  }, stderr = console.error, stdout = console.log, brief, description, examples, author, bugs, footer } = options;
824
824
  let maxWidth = requestedMaxWidth;
@@ -1033,6 +1033,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
1033
1033
  termWidth,
1034
1034
  showDefault,
1035
1035
  showChoices,
1036
+ showAliases,
1036
1037
  showEnvironment,
1037
1038
  sectionOrder,
1038
1039
  showUsage
@@ -1111,6 +1112,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
1111
1112
  termWidth,
1112
1113
  showDefault,
1113
1114
  showChoices,
1115
+ showAliases,
1114
1116
  showEnvironment,
1115
1117
  sectionOrder,
1116
1118
  showUsage
@@ -1311,16 +1313,20 @@ function collapseTopLevelCommandEntries(entries) {
1311
1313
  const isTopLevel = entry.term.name === topLevelName;
1312
1314
  if (existingIndex == null) {
1313
1315
  commandIndexes.set(topLevelName, collapsed.length);
1314
- collapsed.push(isTopLevel ? entry : { term: {
1316
+ collapsed.push(isTopLevel ? entry : { term: omitCommandAliases({
1315
1317
  ...entry.term,
1316
1318
  name: topLevelName
1317
- } });
1319
+ }) });
1318
1320
  continue;
1319
1321
  }
1320
1322
  if (isTopLevel) collapsed[existingIndex] = entry;
1321
1323
  }
1322
1324
  return collapsed;
1323
1325
  }
1326
+ function omitCommandAliases(term) {
1327
+ const { aliases: _aliases,...rest } = term;
1328
+ return rest;
1329
+ }
1324
1330
  function getTopLevelCommandName(name) {
1325
1331
  return name.split(" ", 1)[0] ?? name;
1326
1332
  }
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonemp
3
3
  import { Message, MessageFormatOptions, MessageFormatter, MessageFormatterOptions, MessageTerm, ValueSetOptions, commandLine, createMessageFormatter, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.cjs";
4
4
  import { ErrorLabelTerm, LabelTerm, ProgramNameTerm, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, defaultTerminalTheme } from "./terminal.cjs";
5
5
  import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.cjs";
6
- import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, EnvironmentBindingDoc, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden } from "./doc.cjs";
6
+ import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, EnvironmentBindingDoc, ShowAliasesOptions, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden } from "./doc.cjs";
7
7
  import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, OriginOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, normalizeInput, origin, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.cjs";
8
8
  import { CombineModes, DetailedParseResult, DocState, EffectfulCompletionSession, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseDetailed, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.cjs";
9
9
  import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.cjs";
@@ -13,4 +13,4 @@ import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./c
13
13
  import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.cjs";
14
14
  import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, HelpSectionsOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.cjs";
15
15
  import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.cjs";
16
- export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, EnvironmentBindingDoc, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HelpSectionsOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveEnvironmentSection, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeInput, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
16
+ export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, EnvironmentBindingDoc, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HelpSectionsOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowAliasesOptions, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveEnvironmentSection, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeInput, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonemp
3
3
  import { Message, MessageFormatOptions, MessageFormatter, MessageFormatterOptions, MessageTerm, ValueSetOptions, commandLine, createMessageFormatter, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.js";
4
4
  import { ErrorLabelTerm, LabelTerm, ProgramNameTerm, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, defaultTerminalTheme } from "./terminal.js";
5
5
  import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
6
- import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, EnvironmentBindingDoc, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden } from "./doc.js";
6
+ import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, EnvironmentBindingDoc, ShowAliasesOptions, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden } from "./doc.js";
7
7
  import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, OriginOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, normalizeInput, origin, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.js";
8
8
  import { CombineModes, DetailedParseResult, DocState, EffectfulCompletionSession, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseDetailed, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.js";
9
9
  import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.js";
@@ -13,4 +13,4 @@ import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./c
13
13
  import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.js";
14
14
  import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, HelpSectionsOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
15
15
  import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.js";
16
- export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, EnvironmentBindingDoc, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HelpSectionsOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveEnvironmentSection, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeInput, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
16
+ export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, EnvironmentBindingDoc, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HelpSectionsOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowAliasesOptions, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveEnvironmentSection, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeInput, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
@@ -1429,6 +1429,12 @@ function getVisibleCommandAliases(options) {
1429
1429
  if (!isNonEmptyStringArray(aliases)) throw new TypeError("Command aliases must be a non-empty array of strings.");
1430
1430
  return aliases;
1431
1431
  }
1432
+ function getShowCommandAliases(options) {
1433
+ const showAliases = options.showAliases;
1434
+ if (showAliases == null) return void 0;
1435
+ if (typeof showAliases !== "boolean") throw new TypeError("Command showAliases must be a boolean.");
1436
+ return showAliases;
1437
+ }
1432
1438
  function getHiddenCommandAliases(options) {
1433
1439
  const hiddenAliases = options[require_command_alias.hiddenCommandAliasesKey];
1434
1440
  if (hiddenAliases == null) return [];
@@ -1493,10 +1499,12 @@ async function* suggestCommandAsync(context, prefix, name, aliases, parser, opti
1493
1499
  * to the inner parser for the remaining arguments.
1494
1500
  * @throws {TypeError} If `name` is empty, whitespace-only, contains
1495
1501
  * embedded whitespace, or contains control characters.
1502
+ * @throws {TypeError} If `options.showAliases` is present but not a boolean.
1496
1503
  */
1497
1504
  function command(name, parser, options = {}) {
1498
1505
  const commandNames = getCommandNames(name, options);
1499
1506
  const aliases = getVisibleCommandAliases(options);
1507
+ const showAliases = getShowCommandAliases(options);
1500
1508
  const hiddenAliases = getHiddenCommandAliases(options);
1501
1509
  require_validate.validateCommandNames(commandNames, "Command");
1502
1510
  validateUniqueCommandNames(commandNames);
@@ -1697,9 +1705,11 @@ function command(name, parser, options = {}) {
1697
1705
  type: "entry",
1698
1706
  term: {
1699
1707
  type: "command",
1700
- name
1708
+ name,
1709
+ ...aliases.length > 0 && { aliases }
1701
1710
  },
1702
- description: options.brief ?? options.description
1711
+ description: options.brief ?? options.description,
1712
+ ...showAliases != null && { showAliases }
1703
1713
  }]
1704
1714
  };
1705
1715
  }
@@ -465,13 +465,28 @@ interface CommandOptions {
465
465
  /**
466
466
  * Additional names that invoke this command.
467
467
  *
468
- * Aliases are functional at runtime and are suggested by shell completion,
469
- * but are hidden from usage and documentation output. The `name` parameter
470
- * passed to {@link command} remains the canonical display name.
468
+ * Aliases are functional at runtime and are suggested by shell completion.
469
+ * By default they are hidden from usage and documentation output; set
470
+ * {@link showAliases} or the help formatter's `showAliases` option to list
471
+ * them next to the command in command lists. Usage lines always show
472
+ * only the `name` parameter passed to {@link command}, which remains the
473
+ * canonical display name.
471
474
  *
472
475
  * @since 1.1.0
473
476
  */
474
477
  readonly aliases?: readonly [string, ...string[]];
478
+ /**
479
+ * Whether to show {@link aliases} next to this command in command lists
480
+ * of help and documentation output, e.g., `(aliases: i, add)`.
481
+ *
482
+ * When omitted, the help formatter's `showAliases` option decides, which
483
+ * defaults to hiding aliases. `true` shows them and `false` hides them
484
+ * regardless of that option. This setting does not affect usage lines
485
+ * and does not apply to nested subcommands.
486
+ *
487
+ * @since 1.4.0
488
+ */
489
+ readonly showAliases?: boolean;
475
490
  /**
476
491
  * Error messages customization.
477
492
  * @since 0.5.0
@@ -522,6 +537,7 @@ type CommandState<TState> = undefined | ["matched", string] | ["parsing", TState
522
537
  * to the inner parser for the remaining arguments.
523
538
  * @throws {TypeError} If `name` is empty, whitespace-only, contains
524
539
  * embedded whitespace, or contains control characters.
540
+ * @throws {TypeError} If `options.showAliases` is present but not a boolean.
525
541
  */
526
542
  declare function command<M extends Mode, T, TState>(name: string, parser: Parser<M, T, TState>, options?: CommandOptions): FluentParser<M, T, CommandState<TState>>;
527
543
  /**
@@ -465,13 +465,28 @@ interface CommandOptions {
465
465
  /**
466
466
  * Additional names that invoke this command.
467
467
  *
468
- * Aliases are functional at runtime and are suggested by shell completion,
469
- * but are hidden from usage and documentation output. The `name` parameter
470
- * passed to {@link command} remains the canonical display name.
468
+ * Aliases are functional at runtime and are suggested by shell completion.
469
+ * By default they are hidden from usage and documentation output; set
470
+ * {@link showAliases} or the help formatter's `showAliases` option to list
471
+ * them next to the command in command lists. Usage lines always show
472
+ * only the `name` parameter passed to {@link command}, which remains the
473
+ * canonical display name.
471
474
  *
472
475
  * @since 1.1.0
473
476
  */
474
477
  readonly aliases?: readonly [string, ...string[]];
478
+ /**
479
+ * Whether to show {@link aliases} next to this command in command lists
480
+ * of help and documentation output, e.g., `(aliases: i, add)`.
481
+ *
482
+ * When omitted, the help formatter's `showAliases` option decides, which
483
+ * defaults to hiding aliases. `true` shows them and `false` hides them
484
+ * regardless of that option. This setting does not affect usage lines
485
+ * and does not apply to nested subcommands.
486
+ *
487
+ * @since 1.4.0
488
+ */
489
+ readonly showAliases?: boolean;
475
490
  /**
476
491
  * Error messages customization.
477
492
  * @since 0.5.0
@@ -522,6 +537,7 @@ type CommandState<TState> = undefined | ["matched", string] | ["parsing", TState
522
537
  * to the inner parser for the remaining arguments.
523
538
  * @throws {TypeError} If `name` is empty, whitespace-only, contains
524
539
  * embedded whitespace, or contains control characters.
540
+ * @throws {TypeError} If `options.showAliases` is present but not a boolean.
525
541
  */
526
542
  declare function command<M extends Mode, T, TState>(name: string, parser: Parser<M, T, TState>, options?: CommandOptions): FluentParser<M, T, CommandState<TState>>;
527
543
  /**
@@ -1429,6 +1429,12 @@ function getVisibleCommandAliases(options) {
1429
1429
  if (!isNonEmptyStringArray(aliases)) throw new TypeError("Command aliases must be a non-empty array of strings.");
1430
1430
  return aliases;
1431
1431
  }
1432
+ function getShowCommandAliases(options) {
1433
+ const showAliases = options.showAliases;
1434
+ if (showAliases == null) return void 0;
1435
+ if (typeof showAliases !== "boolean") throw new TypeError("Command showAliases must be a boolean.");
1436
+ return showAliases;
1437
+ }
1432
1438
  function getHiddenCommandAliases(options) {
1433
1439
  const hiddenAliases = options[hiddenCommandAliasesKey];
1434
1440
  if (hiddenAliases == null) return [];
@@ -1493,10 +1499,12 @@ async function* suggestCommandAsync(context, prefix, name, aliases, parser, opti
1493
1499
  * to the inner parser for the remaining arguments.
1494
1500
  * @throws {TypeError} If `name` is empty, whitespace-only, contains
1495
1501
  * embedded whitespace, or contains control characters.
1502
+ * @throws {TypeError} If `options.showAliases` is present but not a boolean.
1496
1503
  */
1497
1504
  function command(name, parser, options = {}) {
1498
1505
  const commandNames = getCommandNames(name, options);
1499
1506
  const aliases = getVisibleCommandAliases(options);
1507
+ const showAliases = getShowCommandAliases(options);
1500
1508
  const hiddenAliases = getHiddenCommandAliases(options);
1501
1509
  validateCommandNames(commandNames, "Command");
1502
1510
  validateUniqueCommandNames(commandNames);
@@ -1697,9 +1705,11 @@ function command(name, parser, options = {}) {
1697
1705
  type: "entry",
1698
1706
  term: {
1699
1707
  type: "command",
1700
- name
1708
+ name,
1709
+ ...aliases.length > 0 && { aliases }
1701
1710
  },
1702
- description: options.brief ?? options.description
1711
+ description: options.brief ?? options.description,
1712
+ ...showAliases != null && { showAliases }
1703
1713
  }]
1704
1714
  };
1705
1715
  }
@@ -288,7 +288,8 @@ function cacheTerminalTheme(theme = {}) {
288
288
  annotationStyles: theme.annotationStyles == null ? void 0 : {
289
289
  default: theme.annotationStyles.default == null ? void 0 : { ...theme.annotationStyles.default },
290
290
  choices: theme.annotationStyles.choices == null ? void 0 : { ...theme.annotationStyles.choices },
291
- environment: theme.annotationStyles.environment == null ? void 0 : { ...theme.annotationStyles.environment }
291
+ environment: theme.annotationStyles.environment == null ? void 0 : { ...theme.annotationStyles.environment },
292
+ aliases: theme.annotationStyles.aliases == null ? void 0 : { ...theme.annotationStyles.aliases }
292
293
  }
293
294
  };
294
295
  }
@@ -288,7 +288,8 @@ function cacheTerminalTheme(theme = {}) {
288
288
  annotationStyles: theme.annotationStyles == null ? void 0 : {
289
289
  default: theme.annotationStyles.default == null ? void 0 : { ...theme.annotationStyles.default },
290
290
  choices: theme.annotationStyles.choices == null ? void 0 : { ...theme.annotationStyles.choices },
291
- environment: theme.annotationStyles.environment == null ? void 0 : { ...theme.annotationStyles.environment }
291
+ environment: theme.annotationStyles.environment == null ? void 0 : { ...theme.annotationStyles.environment },
292
+ aliases: theme.annotationStyles.aliases == null ? void 0 : { ...theme.annotationStyles.aliases }
292
293
  }
293
294
  };
294
295
  }
package/dist/terminal.cjs CHANGED
@@ -50,7 +50,7 @@ const defaultTerminalTheme = {
50
50
  children: [plain(ctx.text)]
51
51
  }),
52
52
  programName: (_term, ctx) => styled(ctx.text, { bold: true }),
53
- label: (term, ctx) => term.kind === "usageSummary" || term.kind === "choices" ? plain(ctx.text) : styled(ctx.text, {
53
+ label: (term, ctx) => term.kind === "usageSummary" || term.kind === "choices" || term.kind === "aliases" ? plain(ctx.text) : styled(ctx.text, {
54
54
  bold: true,
55
55
  dim: true
56
56
  }),
@@ -60,7 +60,9 @@ const defaultTerminalTheme = {
60
60
  "defaultPrefix",
61
61
  "defaultSuffix",
62
62
  "choicesPrefix",
63
- "choicesSuffix"
63
+ "choicesSuffix",
64
+ "aliasesPrefix",
65
+ "aliasesSuffix"
64
66
  ].includes(term.kind) ? plain(ctx.text) : styled(ctx.text, { dim: true }),
65
67
  errorLabel: (_term, ctx) => plain(ctx.text),
66
68
  annotationStyles: {
@@ -17,7 +17,8 @@ interface ProgramNameTerm {
17
17
  interface LabelTerm {
18
18
  readonly type: "label";
19
19
  readonly label: string;
20
- readonly kind: "usage" | "usageSummary" | "section" | "examples" | "author" | "bugs" | "choices";
20
+ readonly kind: "usage" | "usageSummary" | "section" | "examples" | "author" | "bugs" | "choices"
21
+ /** Command alias annotation label. @since 1.4.0 */ | "aliases";
21
22
  }
22
23
  /**
23
24
  * Punctuation supplied by a terminal renderer.
@@ -26,7 +27,9 @@ interface LabelTerm {
26
27
  interface SyntaxPunctuationTerm {
27
28
  readonly type: "syntaxPunctuation";
28
29
  readonly punctuation: string;
29
- readonly kind: "optionalOpen" | "optionalClose" | "groupOpen" | "groupClose" | "alternative" | "ellipsis" | "passthrough" | "optionSeparator" | "messageOptionSeparator" | "defaultPrefix" | "defaultSuffix" | "choicesPrefix" | "choicesSuffix";
30
+ readonly kind: "optionalOpen" | "optionalClose" | "groupOpen" | "groupClose" | "alternative" | "ellipsis" | "passthrough" | "optionSeparator" | "messageOptionSeparator" | "defaultPrefix" | "defaultSuffix" | "choicesPrefix" | "choicesSuffix"
31
+ /** Command alias annotation prefix. @since 1.4.0 */ | "aliasesPrefix"
32
+ /** Command alias annotation suffix. @since 1.4.0 */ | "aliasesSuffix";
30
33
  }
31
34
  /**
32
35
  * The label preceding an error message.
@@ -116,6 +119,8 @@ type TerminalTheme = Partial<Formatters> & {
116
119
  readonly choices?: TerminalStyle;
117
120
  /** Environment annotation style. @since 1.4.0 */
118
121
  readonly environment?: TerminalStyle;
122
+ /** Command alias annotation style. @since 1.4.0 */
123
+ readonly aliases?: TerminalStyle;
119
124
  };
120
125
  };
121
126
  /**
@@ -17,7 +17,8 @@ interface ProgramNameTerm {
17
17
  interface LabelTerm {
18
18
  readonly type: "label";
19
19
  readonly label: string;
20
- readonly kind: "usage" | "usageSummary" | "section" | "examples" | "author" | "bugs" | "choices";
20
+ readonly kind: "usage" | "usageSummary" | "section" | "examples" | "author" | "bugs" | "choices"
21
+ /** Command alias annotation label. @since 1.4.0 */ | "aliases";
21
22
  }
22
23
  /**
23
24
  * Punctuation supplied by a terminal renderer.
@@ -26,7 +27,9 @@ interface LabelTerm {
26
27
  interface SyntaxPunctuationTerm {
27
28
  readonly type: "syntaxPunctuation";
28
29
  readonly punctuation: string;
29
- readonly kind: "optionalOpen" | "optionalClose" | "groupOpen" | "groupClose" | "alternative" | "ellipsis" | "passthrough" | "optionSeparator" | "messageOptionSeparator" | "defaultPrefix" | "defaultSuffix" | "choicesPrefix" | "choicesSuffix";
30
+ readonly kind: "optionalOpen" | "optionalClose" | "groupOpen" | "groupClose" | "alternative" | "ellipsis" | "passthrough" | "optionSeparator" | "messageOptionSeparator" | "defaultPrefix" | "defaultSuffix" | "choicesPrefix" | "choicesSuffix"
31
+ /** Command alias annotation prefix. @since 1.4.0 */ | "aliasesPrefix"
32
+ /** Command alias annotation suffix. @since 1.4.0 */ | "aliasesSuffix";
30
33
  }
31
34
  /**
32
35
  * The label preceding an error message.
@@ -116,6 +119,8 @@ type TerminalTheme = Partial<Formatters> & {
116
119
  readonly choices?: TerminalStyle;
117
120
  /** Environment annotation style. @since 1.4.0 */
118
121
  readonly environment?: TerminalStyle;
122
+ /** Command alias annotation style. @since 1.4.0 */
123
+ readonly aliases?: TerminalStyle;
119
124
  };
120
125
  };
121
126
  /**
package/dist/terminal.js CHANGED
@@ -49,7 +49,7 @@ const defaultTerminalTheme = {
49
49
  children: [plain(ctx.text)]
50
50
  }),
51
51
  programName: (_term, ctx) => styled(ctx.text, { bold: true }),
52
- label: (term, ctx) => term.kind === "usageSummary" || term.kind === "choices" ? plain(ctx.text) : styled(ctx.text, {
52
+ label: (term, ctx) => term.kind === "usageSummary" || term.kind === "choices" || term.kind === "aliases" ? plain(ctx.text) : styled(ctx.text, {
53
53
  bold: true,
54
54
  dim: true
55
55
  }),
@@ -59,7 +59,9 @@ const defaultTerminalTheme = {
59
59
  "defaultPrefix",
60
60
  "defaultSuffix",
61
61
  "choicesPrefix",
62
- "choicesSuffix"
62
+ "choicesSuffix",
63
+ "aliasesPrefix",
64
+ "aliasesSuffix"
63
65
  ].includes(term.kind) ? plain(ctx.text) : styled(ctx.text, { dim: true }),
64
66
  errorLabel: (_term, ctx) => plain(ctx.text),
65
67
  annotationStyles: {
package/dist/usage.d.cts CHANGED
@@ -108,7 +108,9 @@ type UsageTerm =
108
108
  /**
109
109
  * Additional command names that invoke the same parser.
110
110
  * These aliases participate in parsing, completion, and typo
111
- * suggestions, but are not rendered in usage or documentation output.
111
+ * suggestions. They are never rendered in usage lines, and are rendered
112
+ * in documentation command lists only when enabled through
113
+ * `DocEntry.showAliases` or the `showAliases` formatting option.
112
114
  * @since 1.1.0
113
115
  */
114
116
  readonly aliases?: readonly string[];
package/dist/usage.d.ts CHANGED
@@ -108,7 +108,9 @@ type UsageTerm =
108
108
  /**
109
109
  * Additional command names that invoke the same parser.
110
110
  * These aliases participate in parsing, completion, and typo
111
- * suggestions, but are not rendered in usage or documentation output.
111
+ * suggestions. They are never rendered in usage lines, and are rendered
112
+ * in documentation command lists only when enabled through
113
+ * `DocEntry.showAliases` or the `showAliases` formatting option.
112
114
  * @since 1.1.0
113
115
  */
114
116
  readonly aliases?: readonly string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.4.0-dev.2676",
3
+ "version": "1.4.0-dev.2679",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",
@@ -237,7 +237,7 @@
237
237
  },
238
238
  "sideEffects": false,
239
239
  "devDependencies": {
240
- "@optique/env": "1.4.0-dev.2676+e0287473",
240
+ "@optique/env": "1.4.0-dev.2679+3a3a57d2",
241
241
  "@types/node": "^24.0.0",
242
242
  "fast-check": "^4.7.0",
243
243
  "tsdown": "^0.13.0",