@optique/core 1.2.9 → 1.2.11
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 +49 -23
- package/dist/constructs.js +49 -23
- package/dist/displaywidth.cjs +13 -1
- package/dist/displaywidth.d.cts +10 -1
- package/dist/displaywidth.d.ts +10 -1
- package/dist/displaywidth.js +12 -1
- package/dist/doc.cjs +8 -4
- package/dist/doc.js +8 -4
- package/dist/internal/command-doc-metadata.cjs +90 -0
- package/dist/internal/command-doc-metadata.js +87 -0
- package/dist/message.cjs +32 -6
- package/dist/message.js +33 -7
- package/dist/modifiers.cjs +3 -2
- package/dist/modifiers.js +3 -2
- package/dist/primitives.cjs +29 -22
- package/dist/primitives.js +29 -22
- package/package.json +2 -2
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/internal/command-doc-metadata.ts
|
|
3
|
+
function withOrigin(metadata, origin) {
|
|
4
|
+
const result = { ...metadata };
|
|
5
|
+
Object.defineProperty(result, "origin", {
|
|
6
|
+
value: origin,
|
|
7
|
+
enumerable: false
|
|
8
|
+
});
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
const commandDocMetadata = Symbol.for("@optique/core/commandDocMetadata");
|
|
12
|
+
const commandDocCarrier = Symbol.for("@optique/core/commandDocMetadataCarrier");
|
|
13
|
+
/**
|
|
14
|
+
* Reads effective page metadata, including custom collection-level fields.
|
|
15
|
+
* @param docs The child's documentation.
|
|
16
|
+
* @returns Its selected-command metadata, if any.
|
|
17
|
+
*/
|
|
18
|
+
function getCommandDocMetadata(docs) {
|
|
19
|
+
const carrier = docs.fragments[commandDocCarrier];
|
|
20
|
+
if (carrier != null) {
|
|
21
|
+
const brief = docs.brief === carrier.brief ? carrier.metadata.brief : docs.brief;
|
|
22
|
+
const origin = carrier.metadata.origin ?? "entry";
|
|
23
|
+
const customPage = origin === "entry" && (docs.brief !== carrier.brief || docs.footer !== carrier.footer);
|
|
24
|
+
const description = origin === "entry" && !customPage || docs.description === carrier.description ? carrier.metadata.description : docs.description;
|
|
25
|
+
const footer = docs.footer === carrier.footer ? carrier.metadata.footer : docs.footer;
|
|
26
|
+
return withOrigin({
|
|
27
|
+
...brief == null ? {} : { brief },
|
|
28
|
+
...description == null ? {} : { description },
|
|
29
|
+
...footer == null ? {} : { footer }
|
|
30
|
+
}, customPage ? "custom" : origin);
|
|
31
|
+
}
|
|
32
|
+
const metadata = docs[commandDocMetadata];
|
|
33
|
+
if (metadata != null) return metadata;
|
|
34
|
+
return docs.brief != null || docs.description != null || docs.footer != null ? withOrigin({
|
|
35
|
+
brief: docs.brief,
|
|
36
|
+
description: docs.description,
|
|
37
|
+
footer: docs.footer
|
|
38
|
+
}, "custom") : void 0;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Preserves selected-command metadata when rebuilding documentation fragments.
|
|
42
|
+
* @param docs The rebuilt documentation.
|
|
43
|
+
* @param metadata The selected-command metadata to preserve.
|
|
44
|
+
* @returns Documentation with the internal metadata attached.
|
|
45
|
+
*/
|
|
46
|
+
function withCommandDocMetadata(docs, metadata) {
|
|
47
|
+
if (metadata == null) return docs;
|
|
48
|
+
metadata = withOrigin(metadata, metadata.origin ?? "entry");
|
|
49
|
+
const fragments = [...docs.fragments];
|
|
50
|
+
Object.defineProperty(fragments, commandDocCarrier, { value: {
|
|
51
|
+
metadata,
|
|
52
|
+
brief: docs.brief,
|
|
53
|
+
description: docs.description,
|
|
54
|
+
footer: docs.footer
|
|
55
|
+
} });
|
|
56
|
+
const result = {
|
|
57
|
+
...docs,
|
|
58
|
+
fragments
|
|
59
|
+
};
|
|
60
|
+
Object.defineProperty(result, commandDocMetadata, { value: metadata });
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Collects selected-command metadata in documentation traversal order.
|
|
65
|
+
* @param current Metadata from earlier children.
|
|
66
|
+
* @param docs The next child's documentation.
|
|
67
|
+
* @param includeCustom Whether to retain custom page fields inside merge().
|
|
68
|
+
* @returns The first defined value from children with the same origin.
|
|
69
|
+
*/
|
|
70
|
+
function collectCommandDocMetadata(current, docs, includeCustom = false) {
|
|
71
|
+
const next = getCommandDocMetadata(docs);
|
|
72
|
+
if (next == null) return current;
|
|
73
|
+
const origin = next.origin ?? "entry";
|
|
74
|
+
if (origin === "entry" || origin === "custom" && !includeCustom) return current ?? withOrigin({}, "entry");
|
|
75
|
+
if (current?.origin === "command" && origin !== "command") return current;
|
|
76
|
+
if (current?.origin !== origin) current = void 0;
|
|
77
|
+
const brief = current?.brief ?? next.brief;
|
|
78
|
+
const description = current?.description ?? next.description;
|
|
79
|
+
const footer = current?.footer ?? next.footer;
|
|
80
|
+
return withOrigin({
|
|
81
|
+
...brief == null ? {} : { brief },
|
|
82
|
+
...description == null ? {} : { description },
|
|
83
|
+
...footer == null ? {} : { footer }
|
|
84
|
+
}, origin);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
exports.collectCommandDocMetadata = collectCommandDocMetadata;
|
|
89
|
+
exports.getCommandDocMetadata = getCommandDocMetadata;
|
|
90
|
+
exports.withCommandDocMetadata = withCommandDocMetadata;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//#region src/internal/command-doc-metadata.ts
|
|
2
|
+
function withOrigin(metadata, origin) {
|
|
3
|
+
const result = { ...metadata };
|
|
4
|
+
Object.defineProperty(result, "origin", {
|
|
5
|
+
value: origin,
|
|
6
|
+
enumerable: false
|
|
7
|
+
});
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
const commandDocMetadata = Symbol.for("@optique/core/commandDocMetadata");
|
|
11
|
+
const commandDocCarrier = Symbol.for("@optique/core/commandDocMetadataCarrier");
|
|
12
|
+
/**
|
|
13
|
+
* Reads effective page metadata, including custom collection-level fields.
|
|
14
|
+
* @param docs The child's documentation.
|
|
15
|
+
* @returns Its selected-command metadata, if any.
|
|
16
|
+
*/
|
|
17
|
+
function getCommandDocMetadata(docs) {
|
|
18
|
+
const carrier = docs.fragments[commandDocCarrier];
|
|
19
|
+
if (carrier != null) {
|
|
20
|
+
const brief = docs.brief === carrier.brief ? carrier.metadata.brief : docs.brief;
|
|
21
|
+
const origin = carrier.metadata.origin ?? "entry";
|
|
22
|
+
const customPage = origin === "entry" && (docs.brief !== carrier.brief || docs.footer !== carrier.footer);
|
|
23
|
+
const description = origin === "entry" && !customPage || docs.description === carrier.description ? carrier.metadata.description : docs.description;
|
|
24
|
+
const footer = docs.footer === carrier.footer ? carrier.metadata.footer : docs.footer;
|
|
25
|
+
return withOrigin({
|
|
26
|
+
...brief == null ? {} : { brief },
|
|
27
|
+
...description == null ? {} : { description },
|
|
28
|
+
...footer == null ? {} : { footer }
|
|
29
|
+
}, customPage ? "custom" : origin);
|
|
30
|
+
}
|
|
31
|
+
const metadata = docs[commandDocMetadata];
|
|
32
|
+
if (metadata != null) return metadata;
|
|
33
|
+
return docs.brief != null || docs.description != null || docs.footer != null ? withOrigin({
|
|
34
|
+
brief: docs.brief,
|
|
35
|
+
description: docs.description,
|
|
36
|
+
footer: docs.footer
|
|
37
|
+
}, "custom") : void 0;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Preserves selected-command metadata when rebuilding documentation fragments.
|
|
41
|
+
* @param docs The rebuilt documentation.
|
|
42
|
+
* @param metadata The selected-command metadata to preserve.
|
|
43
|
+
* @returns Documentation with the internal metadata attached.
|
|
44
|
+
*/
|
|
45
|
+
function withCommandDocMetadata(docs, metadata) {
|
|
46
|
+
if (metadata == null) return docs;
|
|
47
|
+
metadata = withOrigin(metadata, metadata.origin ?? "entry");
|
|
48
|
+
const fragments = [...docs.fragments];
|
|
49
|
+
Object.defineProperty(fragments, commandDocCarrier, { value: {
|
|
50
|
+
metadata,
|
|
51
|
+
brief: docs.brief,
|
|
52
|
+
description: docs.description,
|
|
53
|
+
footer: docs.footer
|
|
54
|
+
} });
|
|
55
|
+
const result = {
|
|
56
|
+
...docs,
|
|
57
|
+
fragments
|
|
58
|
+
};
|
|
59
|
+
Object.defineProperty(result, commandDocMetadata, { value: metadata });
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Collects selected-command metadata in documentation traversal order.
|
|
64
|
+
* @param current Metadata from earlier children.
|
|
65
|
+
* @param docs The next child's documentation.
|
|
66
|
+
* @param includeCustom Whether to retain custom page fields inside merge().
|
|
67
|
+
* @returns The first defined value from children with the same origin.
|
|
68
|
+
*/
|
|
69
|
+
function collectCommandDocMetadata(current, docs, includeCustom = false) {
|
|
70
|
+
const next = getCommandDocMetadata(docs);
|
|
71
|
+
if (next == null) return current;
|
|
72
|
+
const origin = next.origin ?? "entry";
|
|
73
|
+
if (origin === "entry" || origin === "custom" && !includeCustom) return current ?? withOrigin({}, "entry");
|
|
74
|
+
if (current?.origin === "command" && origin !== "command") return current;
|
|
75
|
+
if (current?.origin !== origin) current = void 0;
|
|
76
|
+
const brief = current?.brief ?? next.brief;
|
|
77
|
+
const description = current?.description ?? next.description;
|
|
78
|
+
const footer = current?.footer ?? next.footer;
|
|
79
|
+
return withOrigin({
|
|
80
|
+
...brief == null ? {} : { brief },
|
|
81
|
+
...description == null ? {} : { description },
|
|
82
|
+
...footer == null ? {} : { footer }
|
|
83
|
+
}, origin);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { collectCommandDocMetadata, getCommandDocMetadata, withCommandDocMetadata };
|
package/dist/message.cjs
CHANGED
|
@@ -324,7 +324,8 @@ function formatMessage(msg, options = {}) {
|
|
|
324
324
|
if (match == null) break;
|
|
325
325
|
yield {
|
|
326
326
|
text: match[0],
|
|
327
|
-
width: require_displaywidth.getDisplayWidth(match[0])
|
|
327
|
+
width: require_displaywidth.getDisplayWidth(match[0]),
|
|
328
|
+
trimOnWrap: true
|
|
328
329
|
};
|
|
329
330
|
}
|
|
330
331
|
}
|
|
@@ -332,7 +333,8 @@ function formatMessage(msg, options = {}) {
|
|
|
332
333
|
const normalizedText = rawText.replace(/\n/g, " ");
|
|
333
334
|
if (normalizedText.trim() === "" && normalizedText.length > 0) yield {
|
|
334
335
|
text: " ",
|
|
335
|
-
width: 1
|
|
336
|
+
width: 1,
|
|
337
|
+
trimOnWrap: true
|
|
336
338
|
};
|
|
337
339
|
else {
|
|
338
340
|
wordPattern.lastIndex = 0;
|
|
@@ -341,7 +343,8 @@ function formatMessage(msg, options = {}) {
|
|
|
341
343
|
if (match == null) break;
|
|
342
344
|
yield {
|
|
343
345
|
text: match[0],
|
|
344
|
-
width: require_displaywidth.getDisplayWidth(match[0])
|
|
346
|
+
width: require_displaywidth.getDisplayWidth(match[0]),
|
|
347
|
+
trimOnWrap: true
|
|
345
348
|
};
|
|
346
349
|
}
|
|
347
350
|
}
|
|
@@ -381,7 +384,8 @@ function formatMessage(msg, options = {}) {
|
|
|
381
384
|
} else if (term.type === "values") for (let i = 0; i < term.values.length; i++) {
|
|
382
385
|
if (i > 0) yield {
|
|
383
386
|
text: " ",
|
|
384
|
-
width: 1
|
|
387
|
+
width: 1,
|
|
388
|
+
trimOnWrap: true
|
|
385
389
|
};
|
|
386
390
|
const value$1 = useQuotes ? JSON.stringify(term.values[i]) : term.values[i];
|
|
387
391
|
yield {
|
|
@@ -425,18 +429,40 @@ function formatMessage(msg, options = {}) {
|
|
|
425
429
|
}
|
|
426
430
|
let output = "";
|
|
427
431
|
let totalWidth = options.startWidth ?? 0;
|
|
428
|
-
|
|
432
|
+
let pendingWrap = false;
|
|
433
|
+
let atWrappedLineStart = false;
|
|
434
|
+
for (const token of stream()) {
|
|
435
|
+
let { text: text$1, width } = token;
|
|
429
436
|
if (width === -1) {
|
|
430
437
|
output += text$1;
|
|
431
438
|
totalWidth = 0;
|
|
439
|
+
pendingWrap = false;
|
|
440
|
+
atWrappedLineStart = false;
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
const wraps = pendingWrap || options.maxWidth != null && totalWidth > 0 && totalWidth + width > options.maxWidth;
|
|
444
|
+
if ((wraps || atWrappedLineStart) && token.trimOnWrap) {
|
|
445
|
+
const trimmed = text$1.trimStart();
|
|
446
|
+
width -= require_displaywidth.getDisplayWidth(text$1.slice(0, text$1.length - trimmed.length));
|
|
447
|
+
text$1 = trimmed;
|
|
448
|
+
if (text$1 === "") {
|
|
449
|
+
if (wraps) pendingWrap = true;
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
if (pendingWrap && require_displaywidth.stripAnsi(text$1) === "") {
|
|
454
|
+
output += text$1;
|
|
432
455
|
continue;
|
|
433
456
|
}
|
|
434
|
-
if (
|
|
457
|
+
if (wraps) {
|
|
435
458
|
output += "\n";
|
|
436
459
|
totalWidth = 0;
|
|
460
|
+
pendingWrap = false;
|
|
461
|
+
atWrappedLineStart = true;
|
|
437
462
|
}
|
|
438
463
|
output += text$1;
|
|
439
464
|
totalWidth += width;
|
|
465
|
+
if (width > 0) atWrappedLineStart = false;
|
|
440
466
|
}
|
|
441
467
|
return output;
|
|
442
468
|
}
|
package/dist/message.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDisplayWidth } from "./displaywidth.js";
|
|
1
|
+
import { getDisplayWidth, stripAnsi } from "./displaywidth.js";
|
|
2
2
|
|
|
3
3
|
//#region src/message.ts
|
|
4
4
|
/**
|
|
@@ -324,7 +324,8 @@ function formatMessage(msg, options = {}) {
|
|
|
324
324
|
if (match == null) break;
|
|
325
325
|
yield {
|
|
326
326
|
text: match[0],
|
|
327
|
-
width: getDisplayWidth(match[0])
|
|
327
|
+
width: getDisplayWidth(match[0]),
|
|
328
|
+
trimOnWrap: true
|
|
328
329
|
};
|
|
329
330
|
}
|
|
330
331
|
}
|
|
@@ -332,7 +333,8 @@ function formatMessage(msg, options = {}) {
|
|
|
332
333
|
const normalizedText = rawText.replace(/\n/g, " ");
|
|
333
334
|
if (normalizedText.trim() === "" && normalizedText.length > 0) yield {
|
|
334
335
|
text: " ",
|
|
335
|
-
width: 1
|
|
336
|
+
width: 1,
|
|
337
|
+
trimOnWrap: true
|
|
336
338
|
};
|
|
337
339
|
else {
|
|
338
340
|
wordPattern.lastIndex = 0;
|
|
@@ -341,7 +343,8 @@ function formatMessage(msg, options = {}) {
|
|
|
341
343
|
if (match == null) break;
|
|
342
344
|
yield {
|
|
343
345
|
text: match[0],
|
|
344
|
-
width: getDisplayWidth(match[0])
|
|
346
|
+
width: getDisplayWidth(match[0]),
|
|
347
|
+
trimOnWrap: true
|
|
345
348
|
};
|
|
346
349
|
}
|
|
347
350
|
}
|
|
@@ -381,7 +384,8 @@ function formatMessage(msg, options = {}) {
|
|
|
381
384
|
} else if (term.type === "values") for (let i = 0; i < term.values.length; i++) {
|
|
382
385
|
if (i > 0) yield {
|
|
383
386
|
text: " ",
|
|
384
|
-
width: 1
|
|
387
|
+
width: 1,
|
|
388
|
+
trimOnWrap: true
|
|
385
389
|
};
|
|
386
390
|
const value$1 = useQuotes ? JSON.stringify(term.values[i]) : term.values[i];
|
|
387
391
|
yield {
|
|
@@ -425,18 +429,40 @@ function formatMessage(msg, options = {}) {
|
|
|
425
429
|
}
|
|
426
430
|
let output = "";
|
|
427
431
|
let totalWidth = options.startWidth ?? 0;
|
|
428
|
-
|
|
432
|
+
let pendingWrap = false;
|
|
433
|
+
let atWrappedLineStart = false;
|
|
434
|
+
for (const token of stream()) {
|
|
435
|
+
let { text: text$1, width } = token;
|
|
429
436
|
if (width === -1) {
|
|
430
437
|
output += text$1;
|
|
431
438
|
totalWidth = 0;
|
|
439
|
+
pendingWrap = false;
|
|
440
|
+
atWrappedLineStart = false;
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
const wraps = pendingWrap || options.maxWidth != null && totalWidth > 0 && totalWidth + width > options.maxWidth;
|
|
444
|
+
if ((wraps || atWrappedLineStart) && token.trimOnWrap) {
|
|
445
|
+
const trimmed = text$1.trimStart();
|
|
446
|
+
width -= getDisplayWidth(text$1.slice(0, text$1.length - trimmed.length));
|
|
447
|
+
text$1 = trimmed;
|
|
448
|
+
if (text$1 === "") {
|
|
449
|
+
if (wraps) pendingWrap = true;
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
if (pendingWrap && stripAnsi(text$1) === "") {
|
|
454
|
+
output += text$1;
|
|
432
455
|
continue;
|
|
433
456
|
}
|
|
434
|
-
if (
|
|
457
|
+
if (wraps) {
|
|
435
458
|
output += "\n";
|
|
436
459
|
totalWidth = 0;
|
|
460
|
+
pendingWrap = false;
|
|
461
|
+
atWrappedLineStart = true;
|
|
437
462
|
}
|
|
438
463
|
output += text$1;
|
|
439
464
|
totalWidth += width;
|
|
465
|
+
if (width > 0) atWrappedLineStart = false;
|
|
440
466
|
}
|
|
441
467
|
return output;
|
|
442
468
|
}
|
package/dist/modifiers.cjs
CHANGED
|
@@ -3,6 +3,7 @@ const require_message = require('./message.cjs');
|
|
|
3
3
|
const require_mode_dispatch = require('./internal/mode-dispatch.cjs');
|
|
4
4
|
const require_internal_parser = require('./internal/parser.cjs');
|
|
5
5
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
6
|
+
const require_command_doc_metadata = require('./internal/command-doc-metadata.cjs');
|
|
6
7
|
const require_passthrough = require('./internal/passthrough.cjs');
|
|
7
8
|
const require_execution_context = require('./execution-context.cjs');
|
|
8
9
|
const require_phase2_seed = require('./phase2-seed.cjs');
|
|
@@ -636,10 +637,10 @@ function withDefault(parser, defaultValue, options) {
|
|
|
636
637
|
};
|
|
637
638
|
return fragment;
|
|
638
639
|
});
|
|
639
|
-
return {
|
|
640
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
640
641
|
...fragments,
|
|
641
642
|
fragments: modifiedFragments
|
|
642
|
-
};
|
|
643
|
+
}, require_command_doc_metadata.getCommandDocMetadata(fragments));
|
|
643
644
|
}
|
|
644
645
|
return fragments;
|
|
645
646
|
}
|
package/dist/modifiers.js
CHANGED
|
@@ -3,6 +3,7 @@ import { formatMessage, message, text } from "./message.js";
|
|
|
3
3
|
import { dispatchByMode, dispatchIterableByMode, mapModeValue, wrapForMode } from "./internal/mode-dispatch.js";
|
|
4
4
|
import { defineInheritedAnnotationParser, defineParseLanes, defineSourceBindingOnlyAnnotationCompletionParser, getOwnParseLanes, unmatchedNonCliDependencySourceStateMarker } from "./internal/parser.js";
|
|
5
5
|
import { getDelegatedAnnotationState, hasDelegatedAnnotationCarrier, isAnnotationWrappedInitialState, normalizeDelegatedAnnotationState, normalizeNestedDelegatedAnnotationState } from "./annotation-state.js";
|
|
6
|
+
import { getCommandDocMetadata, withCommandDocMetadata } from "./internal/command-doc-metadata.js";
|
|
6
7
|
import { defineKnownCompletionLookup, defineOptionMatch, definePassThroughPriority, getKnownCompletion, getOptionMatch, getPassThroughPriority } from "./internal/passthrough.js";
|
|
7
8
|
import { mergeChildExec, withChildContext, withChildExecPath } from "./execution-context.js";
|
|
8
9
|
import { completeOrExtractPhase2Seed, extractPhase2Seed, extractPhase2SeedKey, phase2SeedFromValueResult } from "./phase2-seed.js";
|
|
@@ -636,10 +637,10 @@ function withDefault(parser, defaultValue, options) {
|
|
|
636
637
|
};
|
|
637
638
|
return fragment;
|
|
638
639
|
});
|
|
639
|
-
return {
|
|
640
|
+
return withCommandDocMetadata({
|
|
640
641
|
...fragments,
|
|
641
642
|
fragments: modifiedFragments
|
|
642
|
-
};
|
|
643
|
+
}, getCommandDocMetadata(fragments));
|
|
643
644
|
}
|
|
644
645
|
return fragments;
|
|
645
646
|
}
|
package/dist/primitives.cjs
CHANGED
|
@@ -6,6 +6,7 @@ const require_mode_dispatch = require('./internal/mode-dispatch.cjs');
|
|
|
6
6
|
const require_internal_dependency = require('./internal/dependency.cjs');
|
|
7
7
|
const require_dependency_runtime = require('./dependency-runtime.cjs');
|
|
8
8
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
9
|
+
const require_command_doc_metadata = require('./internal/command-doc-metadata.cjs');
|
|
9
10
|
const require_passthrough = require('./internal/passthrough.cjs');
|
|
10
11
|
const require_command_alias = require('./internal/command-alias.cjs');
|
|
11
12
|
const require_execution_context = require('./execution-context.cjs');
|
|
@@ -640,10 +641,10 @@ function option(...args) {
|
|
|
640
641
|
return suggestOptionSync(optionNames$1, valueParser, require_usage.isSuggestionHidden(options.hidden), options.description, context, prefix);
|
|
641
642
|
},
|
|
642
643
|
getDocFragments(_state, defaultValue) {
|
|
643
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
644
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
644
645
|
fragments: [],
|
|
645
646
|
description: options.description
|
|
646
|
-
};
|
|
647
|
+
}, {});
|
|
647
648
|
const choicesMessage = valueParser?.choices != null && valueParser.choices.length > 0 ? require_message.valueSet(valueParser.choices.map((c) => valueParser.format(c)), {
|
|
648
649
|
fallback: "",
|
|
649
650
|
type: "unit"
|
|
@@ -659,10 +660,10 @@ function option(...args) {
|
|
|
659
660
|
default: defaultValue != null && valueParser != null ? require_message.message`${valueParser.format(defaultValue)}` : void 0,
|
|
660
661
|
choices: choicesMessage
|
|
661
662
|
}];
|
|
662
|
-
return {
|
|
663
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
663
664
|
fragments,
|
|
664
665
|
description: options.description
|
|
665
|
-
};
|
|
666
|
+
}, {});
|
|
666
667
|
},
|
|
667
668
|
[Symbol.for("Deno.customInspect")]() {
|
|
668
669
|
return `option(${optionNames$1.map((o) => JSON.stringify(o)).join(", ")})`;
|
|
@@ -931,10 +932,10 @@ function flag(...args) {
|
|
|
931
932
|
return suggestions;
|
|
932
933
|
},
|
|
933
934
|
getDocFragments(_state, _defaultValue) {
|
|
934
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
935
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
935
936
|
fragments: [],
|
|
936
937
|
description: options.description
|
|
937
|
-
};
|
|
938
|
+
}, {});
|
|
938
939
|
const fragments = [{
|
|
939
940
|
type: "entry",
|
|
940
941
|
term: {
|
|
@@ -943,10 +944,10 @@ function flag(...args) {
|
|
|
943
944
|
},
|
|
944
945
|
description: options.description
|
|
945
946
|
}];
|
|
946
|
-
return {
|
|
947
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
947
948
|
fragments,
|
|
948
949
|
description: options.description
|
|
949
|
-
};
|
|
950
|
+
}, {});
|
|
950
951
|
},
|
|
951
952
|
[Symbol.for("Deno.customInspect")]() {
|
|
952
953
|
return `flag(${optionNames$1.map((o) => JSON.stringify(o)).join(", ")})`;
|
|
@@ -1303,10 +1304,10 @@ function argument(valueParser, options = {}) {
|
|
|
1303
1304
|
return suggestArgumentSync(valueParser, require_usage.isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry, context.exec);
|
|
1304
1305
|
},
|
|
1305
1306
|
getDocFragments(_state, defaultValue) {
|
|
1306
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
1307
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
1307
1308
|
fragments: [],
|
|
1308
1309
|
description: options.description
|
|
1309
|
-
};
|
|
1310
|
+
}, {});
|
|
1310
1311
|
const choicesMessage = valueParser.choices != null && valueParser.choices.length > 0 ? require_message.valueSet(valueParser.choices.map((c) => valueParser.format(c)), {
|
|
1311
1312
|
fallback: "",
|
|
1312
1313
|
type: "unit"
|
|
@@ -1318,10 +1319,10 @@ function argument(valueParser, options = {}) {
|
|
|
1318
1319
|
default: defaultValue == null ? void 0 : require_message.message`${valueParser.format(defaultValue)}`,
|
|
1319
1320
|
choices: choicesMessage
|
|
1320
1321
|
}];
|
|
1321
|
-
return {
|
|
1322
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1322
1323
|
fragments,
|
|
1323
1324
|
description: options.description
|
|
1324
|
-
};
|
|
1325
|
+
}, {});
|
|
1325
1326
|
},
|
|
1326
1327
|
[Symbol.for("Deno.customInspect")]() {
|
|
1327
1328
|
return `argument()`;
|
|
@@ -1672,11 +1673,11 @@ function command(name, parser, options = {}) {
|
|
|
1672
1673
|
getDocFragments(state, defaultValue) {
|
|
1673
1674
|
const commandState = state.kind === "available" ? normalizeCommandState(state.state) : void 0;
|
|
1674
1675
|
if (state.kind === "unavailable" || typeof commandState === "undefined") {
|
|
1675
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
1676
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
1676
1677
|
fragments: [],
|
|
1677
1678
|
description: options.description
|
|
1678
|
-
};
|
|
1679
|
-
return {
|
|
1679
|
+
}, {});
|
|
1680
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1680
1681
|
description: options.description,
|
|
1681
1682
|
fragments: [{
|
|
1682
1683
|
type: "entry",
|
|
@@ -1686,7 +1687,7 @@ function command(name, parser, options = {}) {
|
|
|
1686
1687
|
},
|
|
1687
1688
|
description: options.brief ?? options.description
|
|
1688
1689
|
}]
|
|
1689
|
-
};
|
|
1690
|
+
}, {});
|
|
1690
1691
|
}
|
|
1691
1692
|
const innerState = commandState[0] === "parsing" ? {
|
|
1692
1693
|
kind: "available",
|
|
@@ -1696,12 +1697,18 @@ function command(name, parser, options = {}) {
|
|
|
1696
1697
|
state: getCommandChildState(state.state, parser.initialState, parser)
|
|
1697
1698
|
};
|
|
1698
1699
|
const innerFragments = parser.getDocFragments(innerState, defaultValue);
|
|
1699
|
-
|
|
1700
|
+
const innerMetadata = require_command_doc_metadata.getCommandDocMetadata(innerFragments) ?? innerFragments;
|
|
1701
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1700
1702
|
...innerFragments,
|
|
1701
1703
|
brief: innerFragments.brief ?? options.brief,
|
|
1702
1704
|
description: innerFragments.description ?? options.description,
|
|
1703
1705
|
footer: innerFragments.footer ?? options.footer
|
|
1704
|
-
}
|
|
1706
|
+
}, {
|
|
1707
|
+
origin: "command",
|
|
1708
|
+
brief: innerMetadata?.brief ?? options.brief,
|
|
1709
|
+
description: innerMetadata?.description ?? options.description,
|
|
1710
|
+
footer: innerMetadata?.footer ?? options.footer
|
|
1711
|
+
});
|
|
1705
1712
|
},
|
|
1706
1713
|
[Symbol.for("Deno.customInspect")]() {
|
|
1707
1714
|
return `command(${JSON.stringify(name)})`;
|
|
@@ -1902,18 +1909,18 @@ function passThrough(options = {}) {
|
|
|
1902
1909
|
return [];
|
|
1903
1910
|
},
|
|
1904
1911
|
getDocFragments(_state, _defaultValue) {
|
|
1905
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
1912
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
1906
1913
|
fragments: [],
|
|
1907
1914
|
description: options.description
|
|
1908
|
-
};
|
|
1909
|
-
return {
|
|
1915
|
+
}, {});
|
|
1916
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1910
1917
|
fragments: [{
|
|
1911
1918
|
type: "entry",
|
|
1912
1919
|
term: { type: "passthrough" },
|
|
1913
1920
|
description: options.description
|
|
1914
1921
|
}],
|
|
1915
1922
|
description: options.description
|
|
1916
|
-
};
|
|
1923
|
+
}, {});
|
|
1917
1924
|
},
|
|
1918
1925
|
[Symbol.for("Deno.customInspect")]() {
|
|
1919
1926
|
return `passThrough(${format})`;
|