@optique/core 0.9.0-dev.182 → 0.9.0-dev.184
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/constructs.cjs +28 -12
- package/dist/constructs.js +28 -12
- package/dist/primitives.cjs +38 -6
- package/dist/primitives.d.cts +34 -0
- package/dist/primitives.d.ts +34 -0
- package/dist/primitives.js +38 -6
- package/dist/usage.cjs +12 -6
- package/dist/usage.d.cts +24 -0
- package/dist/usage.d.ts +24 -0
- package/dist/usage.js +12 -6
- package/package.json +1 -1
package/dist/constructs.cjs
CHANGED
|
@@ -666,6 +666,7 @@ function merge(...args) {
|
|
|
666
666
|
usage: parsers.flatMap((p) => p.usage),
|
|
667
667
|
initialState,
|
|
668
668
|
parse(context) {
|
|
669
|
+
let zeroConsumedSuccess = null;
|
|
669
670
|
for (let i = 0; i < parsers.length; i++) {
|
|
670
671
|
const parser = parsers[i];
|
|
671
672
|
let parserState;
|
|
@@ -682,27 +683,42 @@ function merge(...args) {
|
|
|
682
683
|
});
|
|
683
684
|
if (result.success) {
|
|
684
685
|
let newState;
|
|
685
|
-
if (parser.initialState === void 0)
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
686
|
+
if (parser.initialState === void 0) {
|
|
687
|
+
const key = `__parser_${i}`;
|
|
688
|
+
if (result.consumed.length > 0 || result.next.state !== void 0) newState = {
|
|
689
|
+
...context.state,
|
|
690
|
+
[key]: result.next.state
|
|
691
|
+
};
|
|
692
|
+
else newState = { ...context.state };
|
|
693
|
+
} else newState = {
|
|
690
694
|
...context.state,
|
|
691
695
|
...result.next.state
|
|
692
696
|
};
|
|
693
|
-
|
|
697
|
+
const newContext = {
|
|
698
|
+
...context,
|
|
699
|
+
buffer: result.next.buffer,
|
|
700
|
+
optionsTerminated: result.next.optionsTerminated,
|
|
701
|
+
state: newState
|
|
702
|
+
};
|
|
703
|
+
if (result.consumed.length > 0) return {
|
|
694
704
|
success: true,
|
|
695
|
-
next:
|
|
696
|
-
...context,
|
|
697
|
-
buffer: result.next.buffer,
|
|
698
|
-
optionsTerminated: result.next.optionsTerminated,
|
|
699
|
-
state: newState
|
|
700
|
-
},
|
|
705
|
+
next: newContext,
|
|
701
706
|
consumed: result.consumed
|
|
702
707
|
};
|
|
708
|
+
context = newContext;
|
|
709
|
+
if (zeroConsumedSuccess === null) zeroConsumedSuccess = {
|
|
710
|
+
context: newContext,
|
|
711
|
+
consumed: []
|
|
712
|
+
};
|
|
713
|
+
else zeroConsumedSuccess.context = newContext;
|
|
703
714
|
} else if (result.consumed < 1) continue;
|
|
704
715
|
else return result;
|
|
705
716
|
}
|
|
717
|
+
if (zeroConsumedSuccess !== null) return {
|
|
718
|
+
success: true,
|
|
719
|
+
next: zeroConsumedSuccess.context,
|
|
720
|
+
consumed: zeroConsumedSuccess.consumed
|
|
721
|
+
};
|
|
706
722
|
return {
|
|
707
723
|
success: false,
|
|
708
724
|
consumed: 0,
|
package/dist/constructs.js
CHANGED
|
@@ -666,6 +666,7 @@ function merge(...args) {
|
|
|
666
666
|
usage: parsers.flatMap((p) => p.usage),
|
|
667
667
|
initialState,
|
|
668
668
|
parse(context) {
|
|
669
|
+
let zeroConsumedSuccess = null;
|
|
669
670
|
for (let i = 0; i < parsers.length; i++) {
|
|
670
671
|
const parser = parsers[i];
|
|
671
672
|
let parserState;
|
|
@@ -682,27 +683,42 @@ function merge(...args) {
|
|
|
682
683
|
});
|
|
683
684
|
if (result.success) {
|
|
684
685
|
let newState;
|
|
685
|
-
if (parser.initialState === void 0)
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
686
|
+
if (parser.initialState === void 0) {
|
|
687
|
+
const key = `__parser_${i}`;
|
|
688
|
+
if (result.consumed.length > 0 || result.next.state !== void 0) newState = {
|
|
689
|
+
...context.state,
|
|
690
|
+
[key]: result.next.state
|
|
691
|
+
};
|
|
692
|
+
else newState = { ...context.state };
|
|
693
|
+
} else newState = {
|
|
690
694
|
...context.state,
|
|
691
695
|
...result.next.state
|
|
692
696
|
};
|
|
693
|
-
|
|
697
|
+
const newContext = {
|
|
698
|
+
...context,
|
|
699
|
+
buffer: result.next.buffer,
|
|
700
|
+
optionsTerminated: result.next.optionsTerminated,
|
|
701
|
+
state: newState
|
|
702
|
+
};
|
|
703
|
+
if (result.consumed.length > 0) return {
|
|
694
704
|
success: true,
|
|
695
|
-
next:
|
|
696
|
-
...context,
|
|
697
|
-
buffer: result.next.buffer,
|
|
698
|
-
optionsTerminated: result.next.optionsTerminated,
|
|
699
|
-
state: newState
|
|
700
|
-
},
|
|
705
|
+
next: newContext,
|
|
701
706
|
consumed: result.consumed
|
|
702
707
|
};
|
|
708
|
+
context = newContext;
|
|
709
|
+
if (zeroConsumedSuccess === null) zeroConsumedSuccess = {
|
|
710
|
+
context: newContext,
|
|
711
|
+
consumed: []
|
|
712
|
+
};
|
|
713
|
+
else zeroConsumedSuccess.context = newContext;
|
|
703
714
|
} else if (result.consumed < 1) continue;
|
|
704
715
|
else return result;
|
|
705
716
|
}
|
|
717
|
+
if (zeroConsumedSuccess !== null) return {
|
|
718
|
+
success: true,
|
|
719
|
+
next: zeroConsumedSuccess.context,
|
|
720
|
+
consumed: zeroConsumedSuccess.consumed
|
|
721
|
+
};
|
|
706
722
|
return {
|
|
707
723
|
success: false,
|
|
708
724
|
consumed: 0,
|
package/dist/primitives.cjs
CHANGED
|
@@ -67,12 +67,14 @@ function option(...args) {
|
|
|
67
67
|
type: "optional",
|
|
68
68
|
terms: [{
|
|
69
69
|
type: "option",
|
|
70
|
-
names: optionNames$1
|
|
70
|
+
names: optionNames$1,
|
|
71
|
+
...options.hidden && { hidden: true }
|
|
71
72
|
}]
|
|
72
73
|
} : {
|
|
73
74
|
type: "option",
|
|
74
75
|
names: optionNames$1,
|
|
75
|
-
metavar: valueParser.metavar
|
|
76
|
+
metavar: valueParser.metavar,
|
|
77
|
+
...options.hidden && { hidden: true }
|
|
76
78
|
}],
|
|
77
79
|
initialState: valueParser == null ? {
|
|
78
80
|
success: true,
|
|
@@ -218,6 +220,7 @@ function option(...args) {
|
|
|
218
220
|
};
|
|
219
221
|
},
|
|
220
222
|
suggest(context, prefix) {
|
|
223
|
+
if (options.hidden) return [];
|
|
221
224
|
const suggestions = [];
|
|
222
225
|
const equalsIndex = prefix.indexOf("=");
|
|
223
226
|
if (equalsIndex >= 0) {
|
|
@@ -263,6 +266,10 @@ function option(...args) {
|
|
|
263
266
|
return suggestions;
|
|
264
267
|
},
|
|
265
268
|
getDocFragments(_state, defaultValue) {
|
|
269
|
+
if (options.hidden) return {
|
|
270
|
+
fragments: [],
|
|
271
|
+
description: options.description
|
|
272
|
+
};
|
|
266
273
|
const fragments = [{
|
|
267
274
|
type: "entry",
|
|
268
275
|
term: {
|
|
@@ -328,7 +335,8 @@ function flag(...args) {
|
|
|
328
335
|
priority: 10,
|
|
329
336
|
usage: [{
|
|
330
337
|
type: "option",
|
|
331
|
-
names: optionNames$1
|
|
338
|
+
names: optionNames$1,
|
|
339
|
+
...options.hidden && { hidden: true }
|
|
332
340
|
}],
|
|
333
341
|
initialState: void 0,
|
|
334
342
|
parse(context) {
|
|
@@ -435,6 +443,7 @@ function flag(...args) {
|
|
|
435
443
|
};
|
|
436
444
|
},
|
|
437
445
|
suggest(_context, prefix) {
|
|
446
|
+
if (options.hidden) return [];
|
|
438
447
|
const suggestions = [];
|
|
439
448
|
if (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/")) {
|
|
440
449
|
for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
|
|
@@ -448,6 +457,10 @@ function flag(...args) {
|
|
|
448
457
|
return suggestions;
|
|
449
458
|
},
|
|
450
459
|
getDocFragments(_state, _defaultValue) {
|
|
460
|
+
if (options.hidden) return {
|
|
461
|
+
fragments: [],
|
|
462
|
+
description: options.description
|
|
463
|
+
};
|
|
451
464
|
const fragments = [{
|
|
452
465
|
type: "entry",
|
|
453
466
|
term: {
|
|
@@ -482,7 +495,8 @@ function argument(valueParser, options = {}) {
|
|
|
482
495
|
const optionPattern = /^--?[a-z0-9-]+$/i;
|
|
483
496
|
const term = {
|
|
484
497
|
type: "argument",
|
|
485
|
-
metavar: valueParser.metavar
|
|
498
|
+
metavar: valueParser.metavar,
|
|
499
|
+
...options.hidden && { hidden: true }
|
|
486
500
|
};
|
|
487
501
|
return {
|
|
488
502
|
$valueType: [],
|
|
@@ -542,6 +556,7 @@ function argument(valueParser, options = {}) {
|
|
|
542
556
|
};
|
|
543
557
|
},
|
|
544
558
|
suggest(_context, prefix) {
|
|
559
|
+
if (options.hidden) return [];
|
|
545
560
|
const suggestions = [];
|
|
546
561
|
if (valueParser.suggest) {
|
|
547
562
|
const valueSuggestions = valueParser.suggest(prefix);
|
|
@@ -550,6 +565,10 @@ function argument(valueParser, options = {}) {
|
|
|
550
565
|
return suggestions;
|
|
551
566
|
},
|
|
552
567
|
getDocFragments(_state, defaultValue) {
|
|
568
|
+
if (options.hidden) return {
|
|
569
|
+
fragments: [],
|
|
570
|
+
description: options.description
|
|
571
|
+
};
|
|
553
572
|
const fragments = [{
|
|
554
573
|
type: "entry",
|
|
555
574
|
term,
|
|
@@ -586,7 +605,8 @@ function command(name, parser, options = {}) {
|
|
|
586
605
|
priority: 15,
|
|
587
606
|
usage: [{
|
|
588
607
|
type: "command",
|
|
589
|
-
name
|
|
608
|
+
name,
|
|
609
|
+
...options.hidden && { hidden: true }
|
|
590
610
|
}, ...parser.usage],
|
|
591
611
|
initialState: void 0,
|
|
592
612
|
parse(context) {
|
|
@@ -673,6 +693,7 @@ function command(name, parser, options = {}) {
|
|
|
673
693
|
};
|
|
674
694
|
},
|
|
675
695
|
suggest(context, prefix) {
|
|
696
|
+
if (options.hidden) return [];
|
|
676
697
|
const suggestions = [];
|
|
677
698
|
if (context.state === void 0) {
|
|
678
699
|
if (name.startsWith(prefix)) suggestions.push({
|
|
@@ -696,6 +717,10 @@ function command(name, parser, options = {}) {
|
|
|
696
717
|
return suggestions;
|
|
697
718
|
},
|
|
698
719
|
getDocFragments(state, defaultValue) {
|
|
720
|
+
if (options.hidden) return {
|
|
721
|
+
fragments: [],
|
|
722
|
+
description: options.description
|
|
723
|
+
};
|
|
699
724
|
if (state.kind === "unavailable" || typeof state.state === "undefined") return {
|
|
700
725
|
description: options.description,
|
|
701
726
|
fragments: [{
|
|
@@ -777,7 +802,10 @@ function passThrough(options = {}) {
|
|
|
777
802
|
$valueType: [],
|
|
778
803
|
$stateType: [],
|
|
779
804
|
priority: -10,
|
|
780
|
-
usage: [{
|
|
805
|
+
usage: [{
|
|
806
|
+
type: "passthrough",
|
|
807
|
+
...options.hidden && { hidden: true }
|
|
808
|
+
}],
|
|
781
809
|
initialState: [],
|
|
782
810
|
parse(context) {
|
|
783
811
|
if (context.buffer.length < 1) return {
|
|
@@ -874,6 +902,10 @@ function passThrough(options = {}) {
|
|
|
874
902
|
return [];
|
|
875
903
|
},
|
|
876
904
|
getDocFragments(_state, _defaultValue) {
|
|
905
|
+
if (options.hidden) return {
|
|
906
|
+
fragments: [],
|
|
907
|
+
description: options.description
|
|
908
|
+
};
|
|
877
909
|
return {
|
|
878
910
|
fragments: [{
|
|
879
911
|
type: "entry",
|
package/dist/primitives.d.cts
CHANGED
|
@@ -19,6 +19,13 @@ interface OptionOptions {
|
|
|
19
19
|
* The description of the option, which can be used for help messages.
|
|
20
20
|
*/
|
|
21
21
|
readonly description?: Message;
|
|
22
|
+
/**
|
|
23
|
+
* When `true`, hides the option from help text, shell completion
|
|
24
|
+
* suggestions, and "Did you mean?" error suggestions. The option
|
|
25
|
+
* remains fully functional for parsing.
|
|
26
|
+
* @since 0.9.0
|
|
27
|
+
*/
|
|
28
|
+
readonly hidden?: boolean;
|
|
22
29
|
/**
|
|
23
30
|
* Error message customization options.
|
|
24
31
|
* @since 0.5.0
|
|
@@ -118,6 +125,13 @@ interface FlagOptions {
|
|
|
118
125
|
* The description of the flag, which can be used for help messages.
|
|
119
126
|
*/
|
|
120
127
|
readonly description?: Message;
|
|
128
|
+
/**
|
|
129
|
+
* When `true`, hides the flag from help text, shell completion
|
|
130
|
+
* suggestions, and "Did you mean?" error suggestions. The flag
|
|
131
|
+
* remains fully functional for parsing.
|
|
132
|
+
* @since 0.9.0
|
|
133
|
+
*/
|
|
134
|
+
readonly hidden?: boolean;
|
|
121
135
|
/**
|
|
122
136
|
* Error message customization options.
|
|
123
137
|
* @since 0.5.0
|
|
@@ -197,6 +211,13 @@ interface ArgumentOptions {
|
|
|
197
211
|
* The description of the argument, which can be used for help messages.
|
|
198
212
|
*/
|
|
199
213
|
readonly description?: Message;
|
|
214
|
+
/**
|
|
215
|
+
* When `true`, hides the argument from help text, shell completion
|
|
216
|
+
* suggestions, and error suggestions. The argument remains fully
|
|
217
|
+
* functional for parsing.
|
|
218
|
+
* @since 0.9.0
|
|
219
|
+
*/
|
|
220
|
+
readonly hidden?: boolean;
|
|
200
221
|
/**
|
|
201
222
|
* Error message customization options.
|
|
202
223
|
* @since 0.5.0
|
|
@@ -260,6 +281,13 @@ interface CommandOptions {
|
|
|
260
281
|
* @since 0.6.0
|
|
261
282
|
*/
|
|
262
283
|
readonly footer?: Message;
|
|
284
|
+
/**
|
|
285
|
+
* When `true`, hides the command from help text, shell completion
|
|
286
|
+
* suggestions, and "Did you mean?" error suggestions. The command
|
|
287
|
+
* remains fully functional for parsing.
|
|
288
|
+
* @since 0.9.0
|
|
289
|
+
*/
|
|
290
|
+
readonly hidden?: boolean;
|
|
263
291
|
/**
|
|
264
292
|
* Error messages customization.
|
|
265
293
|
* @since 0.5.0
|
|
@@ -336,6 +364,12 @@ interface PassThroughOptions {
|
|
|
336
364
|
* A description of what pass-through options are used for.
|
|
337
365
|
*/
|
|
338
366
|
readonly description?: Message;
|
|
367
|
+
/**
|
|
368
|
+
* When `true`, hides the pass-through from help text and shell
|
|
369
|
+
* completion suggestions. The parser remains fully functional.
|
|
370
|
+
* @since 0.9.0
|
|
371
|
+
*/
|
|
372
|
+
readonly hidden?: boolean;
|
|
339
373
|
}
|
|
340
374
|
/**
|
|
341
375
|
* Creates a parser that collects unrecognized options and passes them through.
|
package/dist/primitives.d.ts
CHANGED
|
@@ -19,6 +19,13 @@ interface OptionOptions {
|
|
|
19
19
|
* The description of the option, which can be used for help messages.
|
|
20
20
|
*/
|
|
21
21
|
readonly description?: Message;
|
|
22
|
+
/**
|
|
23
|
+
* When `true`, hides the option from help text, shell completion
|
|
24
|
+
* suggestions, and "Did you mean?" error suggestions. The option
|
|
25
|
+
* remains fully functional for parsing.
|
|
26
|
+
* @since 0.9.0
|
|
27
|
+
*/
|
|
28
|
+
readonly hidden?: boolean;
|
|
22
29
|
/**
|
|
23
30
|
* Error message customization options.
|
|
24
31
|
* @since 0.5.0
|
|
@@ -118,6 +125,13 @@ interface FlagOptions {
|
|
|
118
125
|
* The description of the flag, which can be used for help messages.
|
|
119
126
|
*/
|
|
120
127
|
readonly description?: Message;
|
|
128
|
+
/**
|
|
129
|
+
* When `true`, hides the flag from help text, shell completion
|
|
130
|
+
* suggestions, and "Did you mean?" error suggestions. The flag
|
|
131
|
+
* remains fully functional for parsing.
|
|
132
|
+
* @since 0.9.0
|
|
133
|
+
*/
|
|
134
|
+
readonly hidden?: boolean;
|
|
121
135
|
/**
|
|
122
136
|
* Error message customization options.
|
|
123
137
|
* @since 0.5.0
|
|
@@ -197,6 +211,13 @@ interface ArgumentOptions {
|
|
|
197
211
|
* The description of the argument, which can be used for help messages.
|
|
198
212
|
*/
|
|
199
213
|
readonly description?: Message;
|
|
214
|
+
/**
|
|
215
|
+
* When `true`, hides the argument from help text, shell completion
|
|
216
|
+
* suggestions, and error suggestions. The argument remains fully
|
|
217
|
+
* functional for parsing.
|
|
218
|
+
* @since 0.9.0
|
|
219
|
+
*/
|
|
220
|
+
readonly hidden?: boolean;
|
|
200
221
|
/**
|
|
201
222
|
* Error message customization options.
|
|
202
223
|
* @since 0.5.0
|
|
@@ -260,6 +281,13 @@ interface CommandOptions {
|
|
|
260
281
|
* @since 0.6.0
|
|
261
282
|
*/
|
|
262
283
|
readonly footer?: Message;
|
|
284
|
+
/**
|
|
285
|
+
* When `true`, hides the command from help text, shell completion
|
|
286
|
+
* suggestions, and "Did you mean?" error suggestions. The command
|
|
287
|
+
* remains fully functional for parsing.
|
|
288
|
+
* @since 0.9.0
|
|
289
|
+
*/
|
|
290
|
+
readonly hidden?: boolean;
|
|
263
291
|
/**
|
|
264
292
|
* Error messages customization.
|
|
265
293
|
* @since 0.5.0
|
|
@@ -336,6 +364,12 @@ interface PassThroughOptions {
|
|
|
336
364
|
* A description of what pass-through options are used for.
|
|
337
365
|
*/
|
|
338
366
|
readonly description?: Message;
|
|
367
|
+
/**
|
|
368
|
+
* When `true`, hides the pass-through from help text and shell
|
|
369
|
+
* completion suggestions. The parser remains fully functional.
|
|
370
|
+
* @since 0.9.0
|
|
371
|
+
*/
|
|
372
|
+
readonly hidden?: boolean;
|
|
339
373
|
}
|
|
340
374
|
/**
|
|
341
375
|
* Creates a parser that collects unrecognized options and passes them through.
|
package/dist/primitives.js
CHANGED
|
@@ -67,12 +67,14 @@ function option(...args) {
|
|
|
67
67
|
type: "optional",
|
|
68
68
|
terms: [{
|
|
69
69
|
type: "option",
|
|
70
|
-
names: optionNames$1
|
|
70
|
+
names: optionNames$1,
|
|
71
|
+
...options.hidden && { hidden: true }
|
|
71
72
|
}]
|
|
72
73
|
} : {
|
|
73
74
|
type: "option",
|
|
74
75
|
names: optionNames$1,
|
|
75
|
-
metavar: valueParser.metavar
|
|
76
|
+
metavar: valueParser.metavar,
|
|
77
|
+
...options.hidden && { hidden: true }
|
|
76
78
|
}],
|
|
77
79
|
initialState: valueParser == null ? {
|
|
78
80
|
success: true,
|
|
@@ -218,6 +220,7 @@ function option(...args) {
|
|
|
218
220
|
};
|
|
219
221
|
},
|
|
220
222
|
suggest(context, prefix) {
|
|
223
|
+
if (options.hidden) return [];
|
|
221
224
|
const suggestions = [];
|
|
222
225
|
const equalsIndex = prefix.indexOf("=");
|
|
223
226
|
if (equalsIndex >= 0) {
|
|
@@ -263,6 +266,10 @@ function option(...args) {
|
|
|
263
266
|
return suggestions;
|
|
264
267
|
},
|
|
265
268
|
getDocFragments(_state, defaultValue) {
|
|
269
|
+
if (options.hidden) return {
|
|
270
|
+
fragments: [],
|
|
271
|
+
description: options.description
|
|
272
|
+
};
|
|
266
273
|
const fragments = [{
|
|
267
274
|
type: "entry",
|
|
268
275
|
term: {
|
|
@@ -328,7 +335,8 @@ function flag(...args) {
|
|
|
328
335
|
priority: 10,
|
|
329
336
|
usage: [{
|
|
330
337
|
type: "option",
|
|
331
|
-
names: optionNames$1
|
|
338
|
+
names: optionNames$1,
|
|
339
|
+
...options.hidden && { hidden: true }
|
|
332
340
|
}],
|
|
333
341
|
initialState: void 0,
|
|
334
342
|
parse(context) {
|
|
@@ -435,6 +443,7 @@ function flag(...args) {
|
|
|
435
443
|
};
|
|
436
444
|
},
|
|
437
445
|
suggest(_context, prefix) {
|
|
446
|
+
if (options.hidden) return [];
|
|
438
447
|
const suggestions = [];
|
|
439
448
|
if (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/")) {
|
|
440
449
|
for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
|
|
@@ -448,6 +457,10 @@ function flag(...args) {
|
|
|
448
457
|
return suggestions;
|
|
449
458
|
},
|
|
450
459
|
getDocFragments(_state, _defaultValue) {
|
|
460
|
+
if (options.hidden) return {
|
|
461
|
+
fragments: [],
|
|
462
|
+
description: options.description
|
|
463
|
+
};
|
|
451
464
|
const fragments = [{
|
|
452
465
|
type: "entry",
|
|
453
466
|
term: {
|
|
@@ -482,7 +495,8 @@ function argument(valueParser, options = {}) {
|
|
|
482
495
|
const optionPattern = /^--?[a-z0-9-]+$/i;
|
|
483
496
|
const term = {
|
|
484
497
|
type: "argument",
|
|
485
|
-
metavar: valueParser.metavar
|
|
498
|
+
metavar: valueParser.metavar,
|
|
499
|
+
...options.hidden && { hidden: true }
|
|
486
500
|
};
|
|
487
501
|
return {
|
|
488
502
|
$valueType: [],
|
|
@@ -542,6 +556,7 @@ function argument(valueParser, options = {}) {
|
|
|
542
556
|
};
|
|
543
557
|
},
|
|
544
558
|
suggest(_context, prefix) {
|
|
559
|
+
if (options.hidden) return [];
|
|
545
560
|
const suggestions = [];
|
|
546
561
|
if (valueParser.suggest) {
|
|
547
562
|
const valueSuggestions = valueParser.suggest(prefix);
|
|
@@ -550,6 +565,10 @@ function argument(valueParser, options = {}) {
|
|
|
550
565
|
return suggestions;
|
|
551
566
|
},
|
|
552
567
|
getDocFragments(_state, defaultValue) {
|
|
568
|
+
if (options.hidden) return {
|
|
569
|
+
fragments: [],
|
|
570
|
+
description: options.description
|
|
571
|
+
};
|
|
553
572
|
const fragments = [{
|
|
554
573
|
type: "entry",
|
|
555
574
|
term,
|
|
@@ -586,7 +605,8 @@ function command(name, parser, options = {}) {
|
|
|
586
605
|
priority: 15,
|
|
587
606
|
usage: [{
|
|
588
607
|
type: "command",
|
|
589
|
-
name
|
|
608
|
+
name,
|
|
609
|
+
...options.hidden && { hidden: true }
|
|
590
610
|
}, ...parser.usage],
|
|
591
611
|
initialState: void 0,
|
|
592
612
|
parse(context) {
|
|
@@ -673,6 +693,7 @@ function command(name, parser, options = {}) {
|
|
|
673
693
|
};
|
|
674
694
|
},
|
|
675
695
|
suggest(context, prefix) {
|
|
696
|
+
if (options.hidden) return [];
|
|
676
697
|
const suggestions = [];
|
|
677
698
|
if (context.state === void 0) {
|
|
678
699
|
if (name.startsWith(prefix)) suggestions.push({
|
|
@@ -696,6 +717,10 @@ function command(name, parser, options = {}) {
|
|
|
696
717
|
return suggestions;
|
|
697
718
|
},
|
|
698
719
|
getDocFragments(state, defaultValue) {
|
|
720
|
+
if (options.hidden) return {
|
|
721
|
+
fragments: [],
|
|
722
|
+
description: options.description
|
|
723
|
+
};
|
|
699
724
|
if (state.kind === "unavailable" || typeof state.state === "undefined") return {
|
|
700
725
|
description: options.description,
|
|
701
726
|
fragments: [{
|
|
@@ -777,7 +802,10 @@ function passThrough(options = {}) {
|
|
|
777
802
|
$valueType: [],
|
|
778
803
|
$stateType: [],
|
|
779
804
|
priority: -10,
|
|
780
|
-
usage: [{
|
|
805
|
+
usage: [{
|
|
806
|
+
type: "passthrough",
|
|
807
|
+
...options.hidden && { hidden: true }
|
|
808
|
+
}],
|
|
781
809
|
initialState: [],
|
|
782
810
|
parse(context) {
|
|
783
811
|
if (context.buffer.length < 1) return {
|
|
@@ -874,6 +902,10 @@ function passThrough(options = {}) {
|
|
|
874
902
|
return [];
|
|
875
903
|
},
|
|
876
904
|
getDocFragments(_state, _defaultValue) {
|
|
905
|
+
if (options.hidden) return {
|
|
906
|
+
fragments: [],
|
|
907
|
+
description: options.description
|
|
908
|
+
};
|
|
877
909
|
return {
|
|
878
910
|
fragments: [{
|
|
879
911
|
type: "entry",
|
package/dist/usage.cjs
CHANGED
|
@@ -24,8 +24,10 @@ function extractOptionNames(usage) {
|
|
|
24
24
|
const names = /* @__PURE__ */ new Set();
|
|
25
25
|
function traverseUsage(terms) {
|
|
26
26
|
if (!terms || !Array.isArray(terms)) return;
|
|
27
|
-
for (const term of terms) if (term.type === "option")
|
|
28
|
-
|
|
27
|
+
for (const term of terms) if (term.type === "option") {
|
|
28
|
+
if (term.hidden) continue;
|
|
29
|
+
for (const name of term.names) names.add(name);
|
|
30
|
+
} else if (term.type === "optional" || term.type === "multiple") traverseUsage(term.terms);
|
|
29
31
|
else if (term.type === "exclusive") for (const exclusiveUsage of term.terms) traverseUsage(exclusiveUsage);
|
|
30
32
|
}
|
|
31
33
|
traverseUsage(usage);
|
|
@@ -55,8 +57,10 @@ function extractCommandNames(usage) {
|
|
|
55
57
|
const names = /* @__PURE__ */ new Set();
|
|
56
58
|
function traverseUsage(terms) {
|
|
57
59
|
if (!terms || !Array.isArray(terms)) return;
|
|
58
|
-
for (const term of terms) if (term.type === "command")
|
|
59
|
-
|
|
60
|
+
for (const term of terms) if (term.type === "command") {
|
|
61
|
+
if (term.hidden) continue;
|
|
62
|
+
names.add(term.name);
|
|
63
|
+
} else if (term.type === "optional" || term.type === "multiple") traverseUsage(term.terms);
|
|
60
64
|
else if (term.type === "exclusive") for (const exclusiveUsage of term.terms) traverseUsage(exclusiveUsage);
|
|
61
65
|
}
|
|
62
66
|
traverseUsage(usage);
|
|
@@ -87,8 +91,10 @@ function extractArgumentMetavars(usage) {
|
|
|
87
91
|
const metavars = /* @__PURE__ */ new Set();
|
|
88
92
|
function traverseUsage(terms) {
|
|
89
93
|
if (!terms || !Array.isArray(terms)) return;
|
|
90
|
-
for (const term of terms) if (term.type === "argument")
|
|
91
|
-
|
|
94
|
+
for (const term of terms) if (term.type === "argument") {
|
|
95
|
+
if (term.hidden) continue;
|
|
96
|
+
metavars.add(term.metavar);
|
|
97
|
+
} else if (term.type === "optional" || term.type === "multiple") traverseUsage(term.terms);
|
|
92
98
|
else if (term.type === "exclusive") for (const exclusiveUsage of term.terms) traverseUsage(exclusiveUsage);
|
|
93
99
|
}
|
|
94
100
|
traverseUsage(usage);
|
package/dist/usage.d.cts
CHANGED
|
@@ -27,6 +27,12 @@ type UsageTerm =
|
|
|
27
27
|
* the command-line usage.
|
|
28
28
|
*/
|
|
29
29
|
readonly metavar: string;
|
|
30
|
+
/**
|
|
31
|
+
* When `true`, hides the argument from help text, shell completion
|
|
32
|
+
* suggestions, and error suggestions.
|
|
33
|
+
* @since 0.9.0
|
|
34
|
+
*/
|
|
35
|
+
readonly hidden?: boolean;
|
|
30
36
|
}
|
|
31
37
|
/**
|
|
32
38
|
* An option term, which represents a command-line option that can
|
|
@@ -46,6 +52,12 @@ type UsageTerm =
|
|
|
46
52
|
* to indicate what value the option expects.
|
|
47
53
|
*/
|
|
48
54
|
readonly metavar?: string;
|
|
55
|
+
/**
|
|
56
|
+
* When `true`, hides the option from help text, shell completion
|
|
57
|
+
* suggestions, and "Did you mean?" error suggestions.
|
|
58
|
+
* @since 0.9.0
|
|
59
|
+
*/
|
|
60
|
+
readonly hidden?: boolean;
|
|
49
61
|
}
|
|
50
62
|
/**
|
|
51
63
|
* A command term, which represents a subcommand in the command-line
|
|
@@ -60,6 +72,12 @@ type UsageTerm =
|
|
|
60
72
|
* in the command-line usage.
|
|
61
73
|
*/
|
|
62
74
|
readonly name: string;
|
|
75
|
+
/**
|
|
76
|
+
* When `true`, hides the command from help text, shell completion
|
|
77
|
+
* suggestions, and "Did you mean?" error suggestions.
|
|
78
|
+
* @since 0.9.0
|
|
79
|
+
*/
|
|
80
|
+
readonly hidden?: boolean;
|
|
63
81
|
}
|
|
64
82
|
/**
|
|
65
83
|
* An optional term, which represents an optional component
|
|
@@ -133,6 +151,12 @@ type UsageTerm =
|
|
|
133
151
|
* The type of the term, which is always `"passthrough"` for this term.
|
|
134
152
|
*/
|
|
135
153
|
readonly type: "passthrough";
|
|
154
|
+
/**
|
|
155
|
+
* When `true`, hides the pass-through from help text and shell
|
|
156
|
+
* completion suggestions.
|
|
157
|
+
* @since 0.9.0
|
|
158
|
+
*/
|
|
159
|
+
readonly hidden?: boolean;
|
|
136
160
|
};
|
|
137
161
|
/**
|
|
138
162
|
* Represents a command-line usage description, which is a sequence of
|
package/dist/usage.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ type UsageTerm =
|
|
|
27
27
|
* the command-line usage.
|
|
28
28
|
*/
|
|
29
29
|
readonly metavar: string;
|
|
30
|
+
/**
|
|
31
|
+
* When `true`, hides the argument from help text, shell completion
|
|
32
|
+
* suggestions, and error suggestions.
|
|
33
|
+
* @since 0.9.0
|
|
34
|
+
*/
|
|
35
|
+
readonly hidden?: boolean;
|
|
30
36
|
}
|
|
31
37
|
/**
|
|
32
38
|
* An option term, which represents a command-line option that can
|
|
@@ -46,6 +52,12 @@ type UsageTerm =
|
|
|
46
52
|
* to indicate what value the option expects.
|
|
47
53
|
*/
|
|
48
54
|
readonly metavar?: string;
|
|
55
|
+
/**
|
|
56
|
+
* When `true`, hides the option from help text, shell completion
|
|
57
|
+
* suggestions, and "Did you mean?" error suggestions.
|
|
58
|
+
* @since 0.9.0
|
|
59
|
+
*/
|
|
60
|
+
readonly hidden?: boolean;
|
|
49
61
|
}
|
|
50
62
|
/**
|
|
51
63
|
* A command term, which represents a subcommand in the command-line
|
|
@@ -60,6 +72,12 @@ type UsageTerm =
|
|
|
60
72
|
* in the command-line usage.
|
|
61
73
|
*/
|
|
62
74
|
readonly name: string;
|
|
75
|
+
/**
|
|
76
|
+
* When `true`, hides the command from help text, shell completion
|
|
77
|
+
* suggestions, and "Did you mean?" error suggestions.
|
|
78
|
+
* @since 0.9.0
|
|
79
|
+
*/
|
|
80
|
+
readonly hidden?: boolean;
|
|
63
81
|
}
|
|
64
82
|
/**
|
|
65
83
|
* An optional term, which represents an optional component
|
|
@@ -133,6 +151,12 @@ type UsageTerm =
|
|
|
133
151
|
* The type of the term, which is always `"passthrough"` for this term.
|
|
134
152
|
*/
|
|
135
153
|
readonly type: "passthrough";
|
|
154
|
+
/**
|
|
155
|
+
* When `true`, hides the pass-through from help text and shell
|
|
156
|
+
* completion suggestions.
|
|
157
|
+
* @since 0.9.0
|
|
158
|
+
*/
|
|
159
|
+
readonly hidden?: boolean;
|
|
136
160
|
};
|
|
137
161
|
/**
|
|
138
162
|
* Represents a command-line usage description, which is a sequence of
|
package/dist/usage.js
CHANGED
|
@@ -23,8 +23,10 @@ function extractOptionNames(usage) {
|
|
|
23
23
|
const names = /* @__PURE__ */ new Set();
|
|
24
24
|
function traverseUsage(terms) {
|
|
25
25
|
if (!terms || !Array.isArray(terms)) return;
|
|
26
|
-
for (const term of terms) if (term.type === "option")
|
|
27
|
-
|
|
26
|
+
for (const term of terms) if (term.type === "option") {
|
|
27
|
+
if (term.hidden) continue;
|
|
28
|
+
for (const name of term.names) names.add(name);
|
|
29
|
+
} else if (term.type === "optional" || term.type === "multiple") traverseUsage(term.terms);
|
|
28
30
|
else if (term.type === "exclusive") for (const exclusiveUsage of term.terms) traverseUsage(exclusiveUsage);
|
|
29
31
|
}
|
|
30
32
|
traverseUsage(usage);
|
|
@@ -54,8 +56,10 @@ function extractCommandNames(usage) {
|
|
|
54
56
|
const names = /* @__PURE__ */ new Set();
|
|
55
57
|
function traverseUsage(terms) {
|
|
56
58
|
if (!terms || !Array.isArray(terms)) return;
|
|
57
|
-
for (const term of terms) if (term.type === "command")
|
|
58
|
-
|
|
59
|
+
for (const term of terms) if (term.type === "command") {
|
|
60
|
+
if (term.hidden) continue;
|
|
61
|
+
names.add(term.name);
|
|
62
|
+
} else if (term.type === "optional" || term.type === "multiple") traverseUsage(term.terms);
|
|
59
63
|
else if (term.type === "exclusive") for (const exclusiveUsage of term.terms) traverseUsage(exclusiveUsage);
|
|
60
64
|
}
|
|
61
65
|
traverseUsage(usage);
|
|
@@ -86,8 +90,10 @@ function extractArgumentMetavars(usage) {
|
|
|
86
90
|
const metavars = /* @__PURE__ */ new Set();
|
|
87
91
|
function traverseUsage(terms) {
|
|
88
92
|
if (!terms || !Array.isArray(terms)) return;
|
|
89
|
-
for (const term of terms) if (term.type === "argument")
|
|
90
|
-
|
|
93
|
+
for (const term of terms) if (term.type === "argument") {
|
|
94
|
+
if (term.hidden) continue;
|
|
95
|
+
metavars.add(term.metavar);
|
|
96
|
+
} else if (term.type === "optional" || term.type === "multiple") traverseUsage(term.terms);
|
|
91
97
|
else if (term.type === "exclusive") for (const exclusiveUsage of term.terms) traverseUsage(exclusiveUsage);
|
|
92
98
|
}
|
|
93
99
|
traverseUsage(usage);
|