@optique/core 0.9.3 → 0.9.4
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 +9 -0
- package/dist/constructs.js +9 -0
- package/dist/doc.d.cts +6 -0
- package/dist/doc.d.ts +6 -0
- package/dist/facade.cjs +5 -3
- package/dist/facade.js +5 -3
- package/dist/parser.cjs +2 -1
- package/dist/parser.js +2 -1
- package/dist/primitives.cjs +1 -0
- package/dist/primitives.js +1 -0
- package/package.json +1 -1
package/dist/constructs.cjs
CHANGED
|
@@ -314,7 +314,9 @@ function or(...args) {
|
|
|
314
314
|
},
|
|
315
315
|
suggest: createExclusiveSuggest(parsers, isAsync),
|
|
316
316
|
getDocFragments(state, _defaultValue) {
|
|
317
|
+
let brief;
|
|
317
318
|
let description;
|
|
319
|
+
let footer;
|
|
318
320
|
let fragments;
|
|
319
321
|
if (state.kind === "unavailable" || state.state == null) fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }, void 0).fragments);
|
|
320
322
|
else {
|
|
@@ -324,7 +326,9 @@ function or(...args) {
|
|
|
324
326
|
state: parserResult.next.state
|
|
325
327
|
} : { kind: "unavailable" };
|
|
326
328
|
const docFragments = parsers[index].getDocFragments(innerState, void 0);
|
|
329
|
+
brief = docFragments.brief;
|
|
327
330
|
description = docFragments.description;
|
|
331
|
+
footer = docFragments.footer;
|
|
328
332
|
fragments = docFragments.fragments;
|
|
329
333
|
}
|
|
330
334
|
const entries = fragments.filter((f) => f.type === "entry");
|
|
@@ -335,7 +339,9 @@ function or(...args) {
|
|
|
335
339
|
else sections.push(fragment);
|
|
336
340
|
}
|
|
337
341
|
return {
|
|
342
|
+
brief,
|
|
338
343
|
description,
|
|
344
|
+
footer,
|
|
339
345
|
fragments: [...sections.map((s) => ({
|
|
340
346
|
...s,
|
|
341
347
|
type: "section"
|
|
@@ -452,6 +458,7 @@ function longestMatch(...args) {
|
|
|
452
458
|
},
|
|
453
459
|
suggest: createExclusiveSuggest(parsers, isAsync),
|
|
454
460
|
getDocFragments(state, _defaultValue) {
|
|
461
|
+
let brief;
|
|
455
462
|
let description;
|
|
456
463
|
let footer;
|
|
457
464
|
let fragments;
|
|
@@ -463,12 +470,14 @@ function longestMatch(...args) {
|
|
|
463
470
|
kind: "available",
|
|
464
471
|
state: result.next.state
|
|
465
472
|
});
|
|
473
|
+
brief = docResult.brief;
|
|
466
474
|
description = docResult.description;
|
|
467
475
|
footer = docResult.footer;
|
|
468
476
|
fragments = docResult.fragments;
|
|
469
477
|
} else fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }).fragments);
|
|
470
478
|
}
|
|
471
479
|
return {
|
|
480
|
+
brief,
|
|
472
481
|
description,
|
|
473
482
|
fragments,
|
|
474
483
|
footer
|
package/dist/constructs.js
CHANGED
|
@@ -314,7 +314,9 @@ function or(...args) {
|
|
|
314
314
|
},
|
|
315
315
|
suggest: createExclusiveSuggest(parsers, isAsync),
|
|
316
316
|
getDocFragments(state, _defaultValue) {
|
|
317
|
+
let brief;
|
|
317
318
|
let description;
|
|
319
|
+
let footer;
|
|
318
320
|
let fragments;
|
|
319
321
|
if (state.kind === "unavailable" || state.state == null) fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }, void 0).fragments);
|
|
320
322
|
else {
|
|
@@ -324,7 +326,9 @@ function or(...args) {
|
|
|
324
326
|
state: parserResult.next.state
|
|
325
327
|
} : { kind: "unavailable" };
|
|
326
328
|
const docFragments = parsers[index].getDocFragments(innerState, void 0);
|
|
329
|
+
brief = docFragments.brief;
|
|
327
330
|
description = docFragments.description;
|
|
331
|
+
footer = docFragments.footer;
|
|
328
332
|
fragments = docFragments.fragments;
|
|
329
333
|
}
|
|
330
334
|
const entries = fragments.filter((f) => f.type === "entry");
|
|
@@ -335,7 +339,9 @@ function or(...args) {
|
|
|
335
339
|
else sections.push(fragment);
|
|
336
340
|
}
|
|
337
341
|
return {
|
|
342
|
+
brief,
|
|
338
343
|
description,
|
|
344
|
+
footer,
|
|
339
345
|
fragments: [...sections.map((s) => ({
|
|
340
346
|
...s,
|
|
341
347
|
type: "section"
|
|
@@ -452,6 +458,7 @@ function longestMatch(...args) {
|
|
|
452
458
|
},
|
|
453
459
|
suggest: createExclusiveSuggest(parsers, isAsync),
|
|
454
460
|
getDocFragments(state, _defaultValue) {
|
|
461
|
+
let brief;
|
|
455
462
|
let description;
|
|
456
463
|
let footer;
|
|
457
464
|
let fragments;
|
|
@@ -463,12 +470,14 @@ function longestMatch(...args) {
|
|
|
463
470
|
kind: "available",
|
|
464
471
|
state: result.next.state
|
|
465
472
|
});
|
|
473
|
+
brief = docResult.brief;
|
|
466
474
|
description = docResult.description;
|
|
467
475
|
footer = docResult.footer;
|
|
468
476
|
fragments = docResult.fragments;
|
|
469
477
|
} else fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }).fragments);
|
|
470
478
|
}
|
|
471
479
|
return {
|
|
480
|
+
brief,
|
|
472
481
|
description,
|
|
473
482
|
fragments,
|
|
474
483
|
footer
|
package/dist/doc.d.cts
CHANGED
|
@@ -60,6 +60,12 @@ type DocFragment = {
|
|
|
60
60
|
* a final document page.
|
|
61
61
|
*/
|
|
62
62
|
interface DocFragments {
|
|
63
|
+
/**
|
|
64
|
+
* An optional brief that provides a short summary for the collection
|
|
65
|
+
* of fragments.
|
|
66
|
+
* @since 0.7.12
|
|
67
|
+
*/
|
|
68
|
+
readonly brief?: Message;
|
|
63
69
|
/**
|
|
64
70
|
* An optional description that applies to the entire collection of fragments.
|
|
65
71
|
*/
|
package/dist/doc.d.ts
CHANGED
|
@@ -60,6 +60,12 @@ type DocFragment = {
|
|
|
60
60
|
* a final document page.
|
|
61
61
|
*/
|
|
62
62
|
interface DocFragments {
|
|
63
|
+
/**
|
|
64
|
+
* An optional brief that provides a short summary for the collection
|
|
65
|
+
* of fragments.
|
|
66
|
+
* @since 0.7.12
|
|
67
|
+
*/
|
|
68
|
+
readonly brief?: Message;
|
|
63
69
|
/**
|
|
64
70
|
* An optional description that applies to the entire collection of fragments.
|
|
65
71
|
*/
|
package/dist/facade.cjs
CHANGED
|
@@ -556,11 +556,13 @@ function runParser(parser, programName, args, options = {}) {
|
|
|
556
556
|
const displayHelp = (doc) => {
|
|
557
557
|
if (doc != null) {
|
|
558
558
|
const isMetaCommandHelp = (completionName === "singular" || completionName === "both" ? requestedCommand === "completion" : false) || (completionName === "plural" || completionName === "both" ? requestedCommand === "completions" : false) || requestedCommand === "help" || requestedCommand === "version";
|
|
559
|
+
const isSubcommandHelp = classified.commands.length > 0;
|
|
560
|
+
const shouldOverride = !isMetaCommandHelp && !isSubcommandHelp;
|
|
559
561
|
const augmentedDoc = {
|
|
560
562
|
...doc,
|
|
561
|
-
brief:
|
|
562
|
-
description:
|
|
563
|
-
footer:
|
|
563
|
+
brief: shouldOverride ? brief ?? doc.brief : doc.brief ?? brief,
|
|
564
|
+
description: shouldOverride ? description ?? doc.description : doc.description ?? description,
|
|
565
|
+
footer: shouldOverride ? footer ?? doc.footer : doc.footer ?? footer
|
|
564
566
|
};
|
|
565
567
|
stdout(require_doc.formatDocPage(programName, augmentedDoc, {
|
|
566
568
|
colors,
|
package/dist/facade.js
CHANGED
|
@@ -556,11 +556,13 @@ function runParser(parser, programName, args, options = {}) {
|
|
|
556
556
|
const displayHelp = (doc) => {
|
|
557
557
|
if (doc != null) {
|
|
558
558
|
const isMetaCommandHelp = (completionName === "singular" || completionName === "both" ? requestedCommand === "completion" : false) || (completionName === "plural" || completionName === "both" ? requestedCommand === "completions" : false) || requestedCommand === "help" || requestedCommand === "version";
|
|
559
|
+
const isSubcommandHelp = classified.commands.length > 0;
|
|
560
|
+
const shouldOverride = !isMetaCommandHelp && !isSubcommandHelp;
|
|
559
561
|
const augmentedDoc = {
|
|
560
562
|
...doc,
|
|
561
|
-
brief:
|
|
562
|
-
description:
|
|
563
|
-
footer:
|
|
563
|
+
brief: shouldOverride ? brief ?? doc.brief : doc.brief ?? brief,
|
|
564
|
+
description: shouldOverride ? description ?? doc.description : doc.description ?? description,
|
|
565
|
+
footer: shouldOverride ? footer ?? doc.footer : doc.footer ?? footer
|
|
564
566
|
};
|
|
565
567
|
stdout(formatDocPage(programName, augmentedDoc, {
|
|
566
568
|
colors,
|
package/dist/parser.cjs
CHANGED
|
@@ -337,7 +337,7 @@ async function getDocPageAsyncImpl(parser, args) {
|
|
|
337
337
|
* Shared by both sync and async implementations.
|
|
338
338
|
*/
|
|
339
339
|
function buildDocPage(parser, context, args) {
|
|
340
|
-
const { description, fragments, footer } = parser.getDocFragments({
|
|
340
|
+
const { brief, description, fragments, footer } = parser.getDocFragments({
|
|
341
341
|
kind: "available",
|
|
342
342
|
state: context.state
|
|
343
343
|
}, void 0);
|
|
@@ -363,6 +363,7 @@ function buildDocPage(parser, context, args) {
|
|
|
363
363
|
return {
|
|
364
364
|
usage,
|
|
365
365
|
sections,
|
|
366
|
+
...brief != null && { brief },
|
|
366
367
|
...description != null && { description },
|
|
367
368
|
...footer != null && { footer }
|
|
368
369
|
};
|
package/dist/parser.js
CHANGED
|
@@ -337,7 +337,7 @@ async function getDocPageAsyncImpl(parser, args) {
|
|
|
337
337
|
* Shared by both sync and async implementations.
|
|
338
338
|
*/
|
|
339
339
|
function buildDocPage(parser, context, args) {
|
|
340
|
-
const { description, fragments, footer } = parser.getDocFragments({
|
|
340
|
+
const { brief, description, fragments, footer } = parser.getDocFragments({
|
|
341
341
|
kind: "available",
|
|
342
342
|
state: context.state
|
|
343
343
|
}, void 0);
|
|
@@ -363,6 +363,7 @@ function buildDocPage(parser, context, args) {
|
|
|
363
363
|
return {
|
|
364
364
|
usage,
|
|
365
365
|
sections,
|
|
366
|
+
...brief != null && { brief },
|
|
366
367
|
...description != null && { description },
|
|
367
368
|
...footer != null && { footer }
|
|
368
369
|
};
|
package/dist/primitives.cjs
CHANGED
|
@@ -867,6 +867,7 @@ function command(name, parser, options = {}) {
|
|
|
867
867
|
const innerFragments = parser.getDocFragments(innerState, defaultValue);
|
|
868
868
|
return {
|
|
869
869
|
...innerFragments,
|
|
870
|
+
brief: innerFragments.brief ?? options.brief,
|
|
870
871
|
description: innerFragments.description ?? options.description,
|
|
871
872
|
footer: innerFragments.footer ?? options.footer
|
|
872
873
|
};
|
package/dist/primitives.js
CHANGED
|
@@ -867,6 +867,7 @@ function command(name, parser, options = {}) {
|
|
|
867
867
|
const innerFragments = parser.getDocFragments(innerState, defaultValue);
|
|
868
868
|
return {
|
|
869
869
|
...innerFragments,
|
|
870
|
+
brief: innerFragments.brief ?? options.brief,
|
|
870
871
|
description: innerFragments.description ?? options.description,
|
|
871
872
|
footer: innerFragments.footer ?? options.footer
|
|
872
873
|
};
|