@optique/core 0.10.7 → 1.0.0-dev.1116

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 (56) hide show
  1. package/README.md +4 -6
  2. package/dist/annotations.cjs +209 -1
  3. package/dist/annotations.d.cts +78 -1
  4. package/dist/annotations.d.ts +78 -1
  5. package/dist/annotations.js +201 -1
  6. package/dist/completion.cjs +194 -52
  7. package/dist/completion.js +194 -52
  8. package/dist/constructs.cjs +310 -78
  9. package/dist/constructs.d.cts +525 -644
  10. package/dist/constructs.d.ts +525 -644
  11. package/dist/constructs.js +311 -79
  12. package/dist/context.cjs +43 -3
  13. package/dist/context.d.cts +113 -5
  14. package/dist/context.d.ts +113 -5
  15. package/dist/context.js +41 -3
  16. package/dist/dependency.cjs +172 -66
  17. package/dist/dependency.d.cts +22 -2
  18. package/dist/dependency.d.ts +22 -2
  19. package/dist/dependency.js +172 -66
  20. package/dist/doc.cjs +46 -1
  21. package/dist/doc.d.cts +24 -0
  22. package/dist/doc.d.ts +24 -0
  23. package/dist/doc.js +46 -1
  24. package/dist/facade.cjs +702 -322
  25. package/dist/facade.d.cts +124 -190
  26. package/dist/facade.d.ts +124 -190
  27. package/dist/facade.js +703 -323
  28. package/dist/index.cjs +5 -0
  29. package/dist/index.d.cts +5 -5
  30. package/dist/index.d.ts +5 -5
  31. package/dist/index.js +3 -3
  32. package/dist/message.cjs +7 -4
  33. package/dist/message.js +7 -4
  34. package/dist/mode-dispatch.cjs +23 -1
  35. package/dist/mode-dispatch.d.cts +55 -0
  36. package/dist/mode-dispatch.d.ts +55 -0
  37. package/dist/mode-dispatch.js +21 -1
  38. package/dist/modifiers.cjs +210 -55
  39. package/dist/modifiers.js +211 -56
  40. package/dist/parser.cjs +80 -47
  41. package/dist/parser.d.cts +18 -3
  42. package/dist/parser.d.ts +18 -3
  43. package/dist/parser.js +82 -50
  44. package/dist/primitives.cjs +102 -37
  45. package/dist/primitives.d.cts +81 -24
  46. package/dist/primitives.d.ts +81 -24
  47. package/dist/primitives.js +103 -39
  48. package/dist/usage.cjs +88 -6
  49. package/dist/usage.d.cts +51 -13
  50. package/dist/usage.d.ts +51 -13
  51. package/dist/usage.js +85 -7
  52. package/dist/valueparser.cjs +391 -106
  53. package/dist/valueparser.d.cts +62 -10
  54. package/dist/valueparser.d.ts +62 -10
  55. package/dist/valueparser.js +391 -106
  56. package/package.json +10 -1
@@ -1,3 +1,4 @@
1
+ const require_annotations = require('./annotations.cjs');
1
2
  const require_message = require('./message.cjs');
2
3
  const require_dependency = require('./dependency.cjs');
3
4
  const require_mode_dispatch = require('./mode-dispatch.cjs');
@@ -7,6 +8,10 @@ const require_usage_internals = require('./usage-internals.cjs');
7
8
  const require_valueparser = require('./valueparser.cjs');
8
9
 
9
10
  //#region src/primitives.ts
11
+ function hasParsedOptionValue(state, valueParser) {
12
+ if (valueParser != null) return require_dependency.isDeferredParseState(state) || require_dependency.isDependencySourceState(state) || state != null && "success" in state && state.success;
13
+ return state != null && "success" in state && state.success && state.value === true;
14
+ }
10
15
  /**
11
16
  * Helper function to create the appropriate state for an option value.
12
17
  * - If the value parser is a DerivedValueParser, wraps the result in a DeferredParseState
@@ -55,6 +60,54 @@ function constant(value) {
55
60
  };
56
61
  }
57
62
  /**
63
+ * Creates a parser that always fails without consuming any input.
64
+ *
65
+ * This is the counterpart to {@link constant}: while `constant(value)` always
66
+ * succeeds, `fail<T>()` always fails. At the type level it is declared to
67
+ * produce a value of type `T`, so it composes seamlessly with other parsers
68
+ * that expect `Parser<"sync", T, …>`.
69
+ *
70
+ * The primary use case is as the inner parser for
71
+ * `bindConfig(fail<T>(), { … })` when a value should *only* come from a
72
+ * config file and has no corresponding CLI flag or argument. Because `fail()`
73
+ * always fails, `bindConfig` will always fall back to the config file (or the
74
+ * supplied default).
75
+ *
76
+ * @template T The type of value this parser is declared to produce.
77
+ * @returns A {@link Parser} that always fails at parse time and always fails at
78
+ * complete time.
79
+ * @since 1.0.0
80
+ */
81
+ function fail() {
82
+ return {
83
+ $valueType: [],
84
+ $stateType: [],
85
+ $mode: "sync",
86
+ priority: 0,
87
+ usage: [],
88
+ initialState: void 0,
89
+ parse(_context) {
90
+ return {
91
+ success: false,
92
+ consumed: 0,
93
+ error: require_message.message`No value provided.`
94
+ };
95
+ },
96
+ complete(_state) {
97
+ return {
98
+ success: false,
99
+ error: require_message.message`No value provided.`
100
+ };
101
+ },
102
+ suggest(_context, _prefix) {
103
+ return [];
104
+ },
105
+ getDocFragments(_state, _defaultValue) {
106
+ return { fragments: [] };
107
+ }
108
+ };
109
+ }
110
+ /**
58
111
  * Internal helper to get suggestions from a value parser, using dependency values
59
112
  * if the parser is a derived parser and dependency values are available.
60
113
  * @internal
@@ -116,7 +169,8 @@ function* suggestOptionSync(optionNames$1, valueParser, hidden, context, prefix)
116
169
  }
117
170
  }
118
171
  } else {
119
- if (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/")) {
172
+ const expectingValue = context.buffer.length > 0 && optionNames$1.includes(context.buffer[context.buffer.length - 1]);
173
+ if (!expectingValue && (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/"))) {
120
174
  for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
121
175
  if (prefix === "-" && optionName$1.length !== 2) continue;
122
176
  yield {
@@ -197,7 +251,8 @@ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, context,
197
251
  }
198
252
  }
199
253
  } else {
200
- if (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/")) {
254
+ const expectingValue = context.buffer.length > 0 && optionNames$1.includes(context.buffer[context.buffer.length - 1]);
255
+ if (!expectingValue && (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/"))) {
201
256
  for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
202
257
  if (prefix === "-" && optionName$1.length !== 2) continue;
203
258
  yield {
@@ -266,13 +321,13 @@ function option(...args) {
266
321
  terms: [{
267
322
  type: "option",
268
323
  names: optionNames$1,
269
- ...options.hidden && { hidden: true }
324
+ ...options.hidden != null && { hidden: options.hidden }
270
325
  }]
271
326
  } : {
272
327
  type: "option",
273
328
  names: optionNames$1,
274
329
  metavar: valueParser.metavar,
275
- ...options.hidden && { hidden: true }
330
+ ...options.hidden != null && { hidden: options.hidden }
276
331
  }],
277
332
  initialState: valueParser == null ? {
278
333
  success: true,
@@ -303,8 +358,7 @@ function option(...args) {
303
358
  consumed: context.buffer.slice(0, 1)
304
359
  };
305
360
  if (optionNames$1.includes(context.buffer[0])) {
306
- const hasValue = valueParser != null ? context.state?.success || require_dependency.isDeferredParseState(context.state) || require_dependency.isDependencySourceState(context.state) : context.state?.success && context.state?.value;
307
- if (hasValue) return {
361
+ if (hasParsedOptionValue(context.state, valueParser)) return {
308
362
  success: false,
309
363
  consumed: 1,
310
364
  error: options.errors?.duplicate ? typeof options.errors.duplicate === "function" ? options.errors.duplicate(context.buffer[0]) : options.errors.duplicate : require_message.message`${require_message.optionName(context.buffer[0])} cannot be used multiple times.`
@@ -347,14 +401,17 @@ function option(...args) {
347
401
  consumed: context.buffer.slice(0, 2)
348
402
  };
349
403
  }
350
- const prefixes = optionNames$1.filter((name) => name.startsWith("--") || name.startsWith("/")).map((name) => name.startsWith("/") ? `${name}:` : `${name}=`);
404
+ const prefixes = optionNames$1.filter((name) => name.startsWith("--") || name.startsWith("/") || name.startsWith("-") && name.length > 2).map((name) => name.startsWith("/") ? `${name}:` : `${name}=`);
351
405
  for (const prefix of prefixes) {
352
406
  if (!context.buffer[0].startsWith(prefix)) continue;
353
- if (context.state?.success && (valueParser != null || context.state.value)) return {
354
- success: false,
355
- consumed: 1,
356
- error: options.errors?.duplicate ? typeof options.errors.duplicate === "function" ? options.errors.duplicate(prefix) : options.errors.duplicate : require_message.message`${require_message.optionName(prefix)} cannot be used multiple times.`
357
- };
407
+ if (hasParsedOptionValue(context.state, valueParser)) {
408
+ const optionName$1 = prefix.slice(0, -1);
409
+ return {
410
+ success: false,
411
+ consumed: 1,
412
+ error: options.errors?.duplicate ? typeof options.errors.duplicate === "function" ? options.errors.duplicate(prefix) : options.errors.duplicate : require_message.message`${require_message.optionName(optionName$1)} cannot be used multiple times.`
413
+ };
414
+ }
358
415
  const rawInput = context.buffer[0].slice(prefix.length);
359
416
  if (valueParser == null) return {
360
417
  success: false,
@@ -385,7 +442,7 @@ function option(...args) {
385
442
  const shortOptions = optionNames$1.filter((name) => name.match(/^-[^-]$/));
386
443
  for (const shortOption of shortOptions) {
387
444
  if (!context.buffer[0].startsWith(shortOption)) continue;
388
- if (context.state?.success && (valueParser != null || context.state.value)) return {
445
+ if (hasParsedOptionValue(context.state, valueParser)) return {
389
446
  success: false,
390
447
  consumed: 1,
391
448
  error: options.errors?.duplicate ? typeof options.errors.duplicate === "function" ? options.errors.duplicate(shortOption) : options.errors.duplicate : require_message.message`${require_message.optionName(shortOption)} cannot be used multiple times.`
@@ -458,11 +515,11 @@ function option(...args) {
458
515
  };
459
516
  },
460
517
  suggest(context, prefix) {
461
- if (isAsync) return suggestOptionAsync(optionNames$1, valueParser, options.hidden ?? false, context, prefix);
462
- return suggestOptionSync(optionNames$1, valueParser, options.hidden ?? false, context, prefix);
518
+ if (isAsync) return suggestOptionAsync(optionNames$1, valueParser, require_usage.isSuggestionHidden(options.hidden), context, prefix);
519
+ return suggestOptionSync(optionNames$1, valueParser, require_usage.isSuggestionHidden(options.hidden), context, prefix);
463
520
  },
464
521
  getDocFragments(_state, defaultValue) {
465
- if (options.hidden) return {
522
+ if (require_usage.isDocHidden(options.hidden)) return {
466
523
  fragments: [],
467
524
  description: options.description
468
525
  };
@@ -536,7 +593,7 @@ function flag(...args) {
536
593
  usage: [{
537
594
  type: "option",
538
595
  names: optionNames$1,
539
- ...options.hidden && { hidden: true }
596
+ ...options.hidden != null && { hidden: options.hidden }
540
597
  }],
541
598
  initialState: void 0,
542
599
  parse(context) {
@@ -579,7 +636,7 @@ function flag(...args) {
579
636
  consumed: context.buffer.slice(0, 1)
580
637
  };
581
638
  }
582
- const prefixes = optionNames$1.filter((name) => name.startsWith("--") || name.startsWith("/")).map((name) => name.startsWith("/") ? `${name}:` : `${name}=`);
639
+ const prefixes = optionNames$1.filter((name) => name.startsWith("--") || name.startsWith("/") || name.startsWith("-") && name.length > 2).map((name) => name.startsWith("/") ? `${name}:` : `${name}=`);
583
640
  for (const prefix of prefixes) if (context.buffer[0].startsWith(prefix)) {
584
641
  const value = context.buffer[0].slice(prefix.length);
585
642
  return {
@@ -643,7 +700,7 @@ function flag(...args) {
643
700
  };
644
701
  },
645
702
  suggest(_context, prefix) {
646
- if (options.hidden) return [];
703
+ if (require_usage.isSuggestionHidden(options.hidden)) return [];
647
704
  const suggestions = [];
648
705
  if (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/")) {
649
706
  for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
@@ -657,7 +714,7 @@ function flag(...args) {
657
714
  return suggestions;
658
715
  },
659
716
  getDocFragments(_state, _defaultValue) {
660
- if (options.hidden) return {
717
+ if (require_usage.isDocHidden(options.hidden)) return {
661
718
  fragments: [],
662
719
  description: options.description
663
720
  };
@@ -698,7 +755,7 @@ function argument(valueParser, options = {}) {
698
755
  const term = {
699
756
  type: "argument",
700
757
  metavar: valueParser.metavar,
701
- ...options.hidden && { hidden: true }
758
+ ...options.hidden != null && { hidden: options.hidden }
702
759
  };
703
760
  const result = {
704
761
  $mode: valueParser.$mode,
@@ -787,11 +844,11 @@ function argument(valueParser, options = {}) {
787
844
  },
788
845
  suggest(context, prefix) {
789
846
  if (context.state != null) return require_mode_dispatch.dispatchIterableByMode(valueParser.$mode, function* () {}, async function* () {});
790
- if (isAsync) return suggestArgumentAsync(valueParser, options.hidden ?? false, prefix, context.dependencyRegistry);
791
- return suggestArgumentSync(valueParser, options.hidden ?? false, prefix, context.dependencyRegistry);
847
+ if (isAsync) return suggestArgumentAsync(valueParser, require_usage.isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry);
848
+ return suggestArgumentSync(valueParser, require_usage.isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry);
792
849
  },
793
850
  getDocFragments(_state, defaultValue) {
794
- if (options.hidden) return {
851
+ if (require_usage.isDocHidden(options.hidden)) return {
795
852
  fragments: [],
796
853
  description: options.description
797
854
  };
@@ -815,7 +872,7 @@ function argument(valueParser, options = {}) {
815
872
  return result;
816
873
  }
817
874
  function* suggestCommandSync(context, prefix, name, parser, options) {
818
- if (options.hidden) return;
875
+ if (require_usage.isSuggestionHidden(options.hidden)) return;
819
876
  if (context.state === void 0) {
820
877
  if (name.startsWith(prefix)) yield {
821
878
  kind: "literal",
@@ -832,7 +889,7 @@ function* suggestCommandSync(context, prefix, name, parser, options) {
832
889
  }, prefix);
833
890
  }
834
891
  async function* suggestCommandAsync(context, prefix, name, parser, options) {
835
- if (options.hidden) return;
892
+ if (require_usage.isSuggestionHidden(options.hidden)) return;
836
893
  if (context.state === void 0) {
837
894
  if (name.startsWith(prefix)) yield {
838
895
  kind: "literal",
@@ -870,6 +927,7 @@ async function* suggestCommandAsync(context, prefix, name, parser, options) {
870
927
  function command(name, parser, options = {}) {
871
928
  const isAsync = parser.$mode === "async";
872
929
  const result = {
930
+ [Symbol.for("@optique/core/commandParser")]: true,
873
931
  $mode: parser.$mode,
874
932
  $valueType: [],
875
933
  $stateType: [],
@@ -877,7 +935,8 @@ function command(name, parser, options = {}) {
877
935
  usage: [{
878
936
  type: "command",
879
937
  name,
880
- ...options.hidden && { hidden: true }
938
+ ...options.usageLine != null && { usageLine: options.usageLine },
939
+ ...options.hidden != null && { hidden: options.hidden }
881
940
  }, ...parser.usage],
882
941
  initialState: void 0,
883
942
  parse(context) {
@@ -977,7 +1036,7 @@ function command(name, parser, options = {}) {
977
1036
  },
978
1037
  getDocFragments(state, defaultValue) {
979
1038
  if (state.kind === "unavailable" || typeof state.state === "undefined") {
980
- if (options.hidden) return {
1039
+ if (require_usage.isDocHidden(options.hidden)) return {
981
1040
  fragments: [],
982
1041
  description: options.description
983
1042
  };
@@ -1071,7 +1130,7 @@ function passThrough(options = {}) {
1071
1130
  priority: -10,
1072
1131
  usage: [{
1073
1132
  type: "passthrough",
1074
- ...options.hidden && { hidden: true }
1133
+ ...options.hidden != null && { hidden: options.hidden }
1075
1134
  }],
1076
1135
  initialState: [],
1077
1136
  parse(context) {
@@ -1088,7 +1147,7 @@ function passThrough(options = {}) {
1088
1147
  next: {
1089
1148
  ...context,
1090
1149
  buffer: [],
1091
- state: [...context.state, ...captured]
1150
+ state: require_annotations.annotateFreshArray(context.state, [...context.state, ...captured])
1092
1151
  },
1093
1152
  consumed: captured
1094
1153
  };
@@ -1109,7 +1168,7 @@ function passThrough(options = {}) {
1109
1168
  next: {
1110
1169
  ...context,
1111
1170
  buffer: context.buffer.slice(1),
1112
- state: [...context.state, token]
1171
+ state: require_annotations.annotateFreshArray(context.state, [...context.state, token])
1113
1172
  },
1114
1173
  consumed: [token]
1115
1174
  };
@@ -1125,7 +1184,7 @@ function passThrough(options = {}) {
1125
1184
  next: {
1126
1185
  ...context,
1127
1186
  buffer: context.buffer.slice(1),
1128
- state: [...context.state, token]
1187
+ state: require_annotations.annotateFreshArray(context.state, [...context.state, token])
1129
1188
  },
1130
1189
  consumed: [token]
1131
1190
  };
@@ -1135,11 +1194,11 @@ function passThrough(options = {}) {
1135
1194
  next: {
1136
1195
  ...context,
1137
1196
  buffer: context.buffer.slice(2),
1138
- state: [
1197
+ state: require_annotations.annotateFreshArray(context.state, [
1139
1198
  ...context.state,
1140
1199
  token,
1141
1200
  nextToken
1142
- ]
1201
+ ])
1143
1202
  },
1144
1203
  consumed: [token, nextToken]
1145
1204
  };
@@ -1148,7 +1207,7 @@ function passThrough(options = {}) {
1148
1207
  next: {
1149
1208
  ...context,
1150
1209
  buffer: context.buffer.slice(1),
1151
- state: [...context.state, token]
1210
+ state: require_annotations.annotateFreshArray(context.state, [...context.state, token])
1152
1211
  },
1153
1212
  consumed: [token]
1154
1213
  };
@@ -1160,16 +1219,21 @@ function passThrough(options = {}) {
1160
1219
  };
1161
1220
  },
1162
1221
  complete(state) {
1163
- return {
1222
+ if (require_annotations.getAnnotations(state) == null) return {
1164
1223
  success: true,
1165
1224
  value: state
1166
1225
  };
1226
+ const copied = [...state];
1227
+ return {
1228
+ success: true,
1229
+ value: copied
1230
+ };
1167
1231
  },
1168
1232
  suggest(_context, _prefix) {
1169
1233
  return [];
1170
1234
  },
1171
1235
  getDocFragments(_state, _defaultValue) {
1172
- if (options.hidden) return {
1236
+ if (require_usage.isDocHidden(options.hidden)) return {
1173
1237
  fragments: [],
1174
1238
  description: options.description
1175
1239
  };
@@ -1192,6 +1256,7 @@ function passThrough(options = {}) {
1192
1256
  exports.argument = argument;
1193
1257
  exports.command = command;
1194
1258
  exports.constant = constant;
1259
+ exports.fail = fail;
1195
1260
  exports.flag = flag;
1196
1261
  exports.option = option;
1197
1262
  exports.passThrough = passThrough;
@@ -1,5 +1,5 @@
1
1
  import { Message } from "./message.cjs";
2
- import { OptionName } from "./usage.cjs";
2
+ import { HiddenVisibility, OptionName, Usage } from "./usage.cjs";
3
3
  import { ValueParser, ValueParserResult } from "./valueparser.cjs";
4
4
  import { DeferredParseState, PendingDependencySourceState } from "./dependency.cjs";
5
5
  import { Mode, Parser } from "./parser.cjs";
@@ -18,6 +18,26 @@ type OptionState<T> = ValueParserResult<T> | DeferredParseState<T> | PendingDepe
18
18
  * @template T The type of the constant value produced by the parser.
19
19
  */
20
20
  declare function constant<const T>(value: T): Parser<"sync", T, T>;
21
+ /**
22
+ * Creates a parser that always fails without consuming any input.
23
+ *
24
+ * This is the counterpart to {@link constant}: while `constant(value)` always
25
+ * succeeds, `fail<T>()` always fails. At the type level it is declared to
26
+ * produce a value of type `T`, so it composes seamlessly with other parsers
27
+ * that expect `Parser<"sync", T, …>`.
28
+ *
29
+ * The primary use case is as the inner parser for
30
+ * `bindConfig(fail<T>(), { … })` when a value should *only* come from a
31
+ * config file and has no corresponding CLI flag or argument. Because `fail()`
32
+ * always fails, `bindConfig` will always fall back to the config file (or the
33
+ * supplied default).
34
+ *
35
+ * @template T The type of value this parser is declared to produce.
36
+ * @returns A {@link Parser} that always fails at parse time and always fails at
37
+ * complete time.
38
+ * @since 1.0.0
39
+ */
40
+ declare function fail<T>(): Parser<"sync", T, undefined>;
21
41
  /**
22
42
  * Options for the {@link option} parser.
23
43
  */
@@ -27,12 +47,16 @@ interface OptionOptions {
27
47
  */
28
48
  readonly description?: Message;
29
49
  /**
30
- * When `true`, hides the option from help text, shell completion
31
- * suggestions, and "Did you mean?" error suggestions. The option
32
- * remains fully functional for parsing.
50
+ * Controls option visibility:
51
+ *
52
+ * - `true`: hide from usage, docs, and suggestions
53
+ * - `"usage"`: hide from usage only
54
+ * - `"doc"`: hide from docs only
55
+ * - `"help"`: hide from usage and docs, keep suggestions
56
+ *
33
57
  * @since 0.9.0
34
58
  */
35
- readonly hidden?: boolean;
59
+ readonly hidden?: HiddenVisibility;
36
60
  /**
37
61
  * Error message customization options.
38
62
  * @since 0.5.0
@@ -84,7 +108,8 @@ interface OptionErrorOptions {
84
108
  }
85
109
  /**
86
110
  * Creates a parser for various styles of command-line options that take an
87
- * argument value, such as `--option=value`, `-o value`, or `/option:value`.
111
+ * argument value, such as `--option=value`, `-option=value`, `-o value`,
112
+ * or `/option:value`.
88
113
  * @template M The execution mode of the parser.
89
114
  * @template T The type of value this parser produces.
90
115
  * @param args The {@link OptionName}s to parse, followed by
@@ -97,7 +122,8 @@ interface OptionErrorOptions {
97
122
  declare function option<M extends Mode, T>(...args: readonly [...readonly OptionName[], ValueParser<M, T>]): Parser<M, T, ValueParserResult<T> | undefined>;
98
123
  /**
99
124
  * Creates a parser for various styles of command-line options that take an
100
- * argument value, such as `--option=value`, `-o value`, or `/option:value`.
125
+ * argument value, such as `--option=value`, `-option=value`, `-o value`,
126
+ * or `/option:value`.
101
127
  * @template M The execution mode of the parser.
102
128
  * @template T The type of value this parser produces.
103
129
  * @param args The {@link OptionName}s to parse, followed by
@@ -118,7 +144,8 @@ declare function option<M extends Mode, T>(...args: readonly [...readonly Option
118
144
  declare function option(...optionNames: readonly OptionName[]): Parser<"sync", boolean, ValueParserResult<boolean> | undefined>;
119
145
  /**
120
146
  * Creates a parser for various styles of command-line options that take an
121
- * argument value, such as `--option=value`, `-o value`, or `/option:value`.
147
+ * argument value, such as `--option=value`, `-option=value`, `-o value`,
148
+ * or `/option:value`.
122
149
  * @param args The {@link OptionName}s to parse, followed by
123
150
  * an optional {@link OptionOptions} object that allows you to
124
151
  * specify a description or other metadata.
@@ -135,12 +162,16 @@ interface FlagOptions {
135
162
  */
136
163
  readonly description?: Message;
137
164
  /**
138
- * When `true`, hides the flag from help text, shell completion
139
- * suggestions, and "Did you mean?" error suggestions. The flag
140
- * remains fully functional for parsing.
165
+ * Controls flag visibility:
166
+ *
167
+ * - `true`: hide from usage, docs, and suggestions
168
+ * - `"usage"`: hide from usage only
169
+ * - `"doc"`: hide from docs only
170
+ * - `"help"`: hide from usage and docs, keep suggestions
171
+ *
141
172
  * @since 0.9.0
142
173
  */
143
- readonly hidden?: boolean;
174
+ readonly hidden?: HiddenVisibility;
144
175
  /**
145
176
  * Error message customization options.
146
177
  * @since 0.5.0
@@ -221,12 +252,16 @@ interface ArgumentOptions {
221
252
  */
222
253
  readonly description?: Message;
223
254
  /**
224
- * When `true`, hides the argument from help text, shell completion
225
- * suggestions, and error suggestions. The argument remains fully
226
- * functional for parsing.
255
+ * Controls argument visibility:
256
+ *
257
+ * - `true`: hide from usage, docs, and suggestions
258
+ * - `"usage"`: hide from usage only
259
+ * - `"doc"`: hide from docs only
260
+ * - `"help"`: hide from usage and docs, keep suggestions
261
+ *
227
262
  * @since 0.9.0
228
263
  */
229
- readonly hidden?: boolean;
264
+ readonly hidden?: HiddenVisibility;
230
265
  /**
231
266
  * Error message customization options.
232
267
  * @since 0.5.0
@@ -292,12 +327,29 @@ interface CommandOptions {
292
327
  */
293
328
  readonly footer?: Message;
294
329
  /**
295
- * When `true`, hides the command from help text, shell completion
296
- * suggestions, and "Did you mean?" error suggestions. The command
297
- * remains fully functional for parsing.
330
+ * Usage line override for this command's own help page.
331
+ *
332
+ * This option customizes the usage tail shown when rendering help for this
333
+ * command itself (e.g., `myapp config --help`). It does not change parsing
334
+ * behavior or shell completion.
335
+ *
336
+ * - `Usage`: Replaces the default usage tail.
337
+ * - `(defaultUsageLine) => Usage`: Computes the usage tail from the default.
338
+ *
339
+ * @since 1.0.0
340
+ */
341
+ readonly usageLine?: Usage | ((defaultUsageLine: Usage) => Usage);
342
+ /**
343
+ * Controls command visibility:
344
+ *
345
+ * - `true`: hide from usage, docs, and suggestions
346
+ * - `"usage"`: hide from usage only
347
+ * - `"doc"`: hide from docs only
348
+ * - `"help"`: hide from usage and docs, keep suggestions
349
+ *
298
350
  * @since 0.9.0
299
351
  */
300
- readonly hidden?: boolean;
352
+ readonly hidden?: HiddenVisibility;
301
353
  /**
302
354
  * Error messages customization.
303
355
  * @since 0.5.0
@@ -376,11 +428,16 @@ interface PassThroughOptions {
376
428
  */
377
429
  readonly description?: Message;
378
430
  /**
379
- * When `true`, hides the pass-through from help text and shell
380
- * completion suggestions. The parser remains fully functional.
431
+ * Controls pass-through visibility:
432
+ *
433
+ * - `true`: hide from usage, docs, and suggestions
434
+ * - `"usage"`: hide from usage only
435
+ * - `"doc"`: hide from docs only
436
+ * - `"help"`: hide from usage and docs, keep suggestions
437
+ *
381
438
  * @since 0.9.0
382
439
  */
383
- readonly hidden?: boolean;
440
+ readonly hidden?: HiddenVisibility;
384
441
  }
385
442
  /**
386
443
  * Creates a parser that collects unrecognized options and passes them through.
@@ -430,4 +487,4 @@ interface PassThroughOptions {
430
487
  */
431
488
  declare function passThrough(options?: PassThroughOptions): Parser<"sync", readonly string[], readonly string[]>;
432
489
  //#endregion
433
- export { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, flag, option, passThrough };
490
+ export { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, option, passThrough };