@optique/core 1.1.9 → 1.1.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');
|
|
@@ -639,10 +640,10 @@ function option(...args) {
|
|
|
639
640
|
return suggestOptionSync(optionNames$1, valueParser, require_usage.isSuggestionHidden(options.hidden), options.description, context, prefix);
|
|
640
641
|
},
|
|
641
642
|
getDocFragments(_state, defaultValue) {
|
|
642
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
643
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
643
644
|
fragments: [],
|
|
644
645
|
description: options.description
|
|
645
|
-
};
|
|
646
|
+
}, {});
|
|
646
647
|
const choicesMessage = valueParser?.choices != null && valueParser.choices.length > 0 ? require_message.valueSet(valueParser.choices.map((c) => valueParser.format(c)), {
|
|
647
648
|
fallback: "",
|
|
648
649
|
type: "unit"
|
|
@@ -658,10 +659,10 @@ function option(...args) {
|
|
|
658
659
|
default: defaultValue != null && valueParser != null ? require_message.message`${valueParser.format(defaultValue)}` : void 0,
|
|
659
660
|
choices: choicesMessage
|
|
660
661
|
}];
|
|
661
|
-
return {
|
|
662
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
662
663
|
fragments,
|
|
663
664
|
description: options.description
|
|
664
|
-
};
|
|
665
|
+
}, {});
|
|
665
666
|
},
|
|
666
667
|
[Symbol.for("Deno.customInspect")]() {
|
|
667
668
|
return `option(${optionNames$1.map((o) => JSON.stringify(o)).join(", ")})`;
|
|
@@ -930,10 +931,10 @@ function flag(...args) {
|
|
|
930
931
|
return suggestions;
|
|
931
932
|
},
|
|
932
933
|
getDocFragments(_state, _defaultValue) {
|
|
933
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
934
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
934
935
|
fragments: [],
|
|
935
936
|
description: options.description
|
|
936
|
-
};
|
|
937
|
+
}, {});
|
|
937
938
|
const fragments = [{
|
|
938
939
|
type: "entry",
|
|
939
940
|
term: {
|
|
@@ -942,10 +943,10 @@ function flag(...args) {
|
|
|
942
943
|
},
|
|
943
944
|
description: options.description
|
|
944
945
|
}];
|
|
945
|
-
return {
|
|
946
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
946
947
|
fragments,
|
|
947
948
|
description: options.description
|
|
948
|
-
};
|
|
949
|
+
}, {});
|
|
949
950
|
},
|
|
950
951
|
[Symbol.for("Deno.customInspect")]() {
|
|
951
952
|
return `flag(${optionNames$1.map((o) => JSON.stringify(o)).join(", ")})`;
|
|
@@ -1302,10 +1303,10 @@ function argument(valueParser, options = {}) {
|
|
|
1302
1303
|
return suggestArgumentSync(valueParser, require_usage.isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry, context.exec);
|
|
1303
1304
|
},
|
|
1304
1305
|
getDocFragments(_state, defaultValue) {
|
|
1305
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
1306
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
1306
1307
|
fragments: [],
|
|
1307
1308
|
description: options.description
|
|
1308
|
-
};
|
|
1309
|
+
}, {});
|
|
1309
1310
|
const choicesMessage = valueParser.choices != null && valueParser.choices.length > 0 ? require_message.valueSet(valueParser.choices.map((c) => valueParser.format(c)), {
|
|
1310
1311
|
fallback: "",
|
|
1311
1312
|
type: "unit"
|
|
@@ -1317,10 +1318,10 @@ function argument(valueParser, options = {}) {
|
|
|
1317
1318
|
default: defaultValue == null ? void 0 : require_message.message`${valueParser.format(defaultValue)}`,
|
|
1318
1319
|
choices: choicesMessage
|
|
1319
1320
|
}];
|
|
1320
|
-
return {
|
|
1321
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1321
1322
|
fragments,
|
|
1322
1323
|
description: options.description
|
|
1323
|
-
};
|
|
1324
|
+
}, {});
|
|
1324
1325
|
},
|
|
1325
1326
|
[Symbol.for("Deno.customInspect")]() {
|
|
1326
1327
|
return `argument()`;
|
|
@@ -1671,11 +1672,11 @@ function command(name, parser, options = {}) {
|
|
|
1671
1672
|
getDocFragments(state, defaultValue) {
|
|
1672
1673
|
const commandState = state.kind === "available" ? normalizeCommandState(state.state) : void 0;
|
|
1673
1674
|
if (state.kind === "unavailable" || typeof commandState === "undefined") {
|
|
1674
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
1675
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
1675
1676
|
fragments: [],
|
|
1676
1677
|
description: options.description
|
|
1677
|
-
};
|
|
1678
|
-
return {
|
|
1678
|
+
}, {});
|
|
1679
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1679
1680
|
description: options.description,
|
|
1680
1681
|
fragments: [{
|
|
1681
1682
|
type: "entry",
|
|
@@ -1685,7 +1686,7 @@ function command(name, parser, options = {}) {
|
|
|
1685
1686
|
},
|
|
1686
1687
|
description: options.brief ?? options.description
|
|
1687
1688
|
}]
|
|
1688
|
-
};
|
|
1689
|
+
}, {});
|
|
1689
1690
|
}
|
|
1690
1691
|
const innerState = commandState[0] === "parsing" ? {
|
|
1691
1692
|
kind: "available",
|
|
@@ -1695,12 +1696,18 @@ function command(name, parser, options = {}) {
|
|
|
1695
1696
|
state: getCommandChildState(state.state, parser.initialState, parser)
|
|
1696
1697
|
};
|
|
1697
1698
|
const innerFragments = parser.getDocFragments(innerState, defaultValue);
|
|
1698
|
-
|
|
1699
|
+
const innerMetadata = require_command_doc_metadata.getCommandDocMetadata(innerFragments) ?? innerFragments;
|
|
1700
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1699
1701
|
...innerFragments,
|
|
1700
1702
|
brief: innerFragments.brief ?? options.brief,
|
|
1701
1703
|
description: innerFragments.description ?? options.description,
|
|
1702
1704
|
footer: innerFragments.footer ?? options.footer
|
|
1703
|
-
}
|
|
1705
|
+
}, {
|
|
1706
|
+
origin: "command",
|
|
1707
|
+
brief: innerMetadata?.brief ?? options.brief,
|
|
1708
|
+
description: innerMetadata?.description ?? options.description,
|
|
1709
|
+
footer: innerMetadata?.footer ?? options.footer
|
|
1710
|
+
});
|
|
1704
1711
|
},
|
|
1705
1712
|
[Symbol.for("Deno.customInspect")]() {
|
|
1706
1713
|
return `command(${JSON.stringify(name)})`;
|
|
@@ -1901,18 +1908,18 @@ function passThrough(options = {}) {
|
|
|
1901
1908
|
return [];
|
|
1902
1909
|
},
|
|
1903
1910
|
getDocFragments(_state, _defaultValue) {
|
|
1904
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
1911
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
1905
1912
|
fragments: [],
|
|
1906
1913
|
description: options.description
|
|
1907
|
-
};
|
|
1908
|
-
return {
|
|
1914
|
+
}, {});
|
|
1915
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1909
1916
|
fragments: [{
|
|
1910
1917
|
type: "entry",
|
|
1911
1918
|
term: { type: "passthrough" },
|
|
1912
1919
|
description: options.description
|
|
1913
1920
|
}],
|
|
1914
1921
|
description: options.description
|
|
1915
|
-
};
|
|
1922
|
+
}, {});
|
|
1916
1923
|
},
|
|
1917
1924
|
[Symbol.for("Deno.customInspect")]() {
|
|
1918
1925
|
return `passThrough(${format})`;
|