@optique/core 1.4.0-dev.2899 → 1.4.0-dev.2935
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 +18 -5
- package/dist/constructs.js +18 -5
- package/dist/doc-pages.cjs +480 -0
- package/dist/doc-pages.d.cts +98 -0
- package/dist/doc-pages.d.ts +98 -0
- package/dist/doc-pages.js +479 -0
- package/dist/facade.cjs +10 -3
- package/dist/facade.d.cts +11 -0
- package/dist/facade.d.ts +11 -0
- package/dist/facade.js +11 -4
- package/dist/internal/doc-metadata.cjs +121 -0
- package/dist/internal/doc-metadata.d.cts +72 -0
- package/dist/internal/doc-metadata.d.ts +72 -0
- package/dist/internal/doc-metadata.js +118 -0
- package/dist/modifiers.cjs +16 -3
- package/dist/modifiers.js +16 -3
- package/dist/primitives.cjs +33 -4
- package/dist/primitives.js +33 -4
- package/dist/usage-internals.cjs +104 -1
- package/dist/usage-internals.js +104 -2
- package/dist/valueparser.cjs +20 -10
- package/dist/valueparser.js +20 -10
- package/package.json +10 -2
- package/skills/optique/SKILL.md +10 -10
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const require_message = require('../message.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/internal/doc-metadata.ts
|
|
4
|
+
const nodes = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
const values = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
const usageSnapshots = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
const termSnapshots = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
function snapshotUsage(usage) {
|
|
9
|
+
const existing = usageSnapshots.get(usage);
|
|
10
|
+
if (existing != null) return existing;
|
|
11
|
+
const snapshot = Object.freeze(usage.map(snapshotUsageTerm));
|
|
12
|
+
usageSnapshots.set(usage, snapshot);
|
|
13
|
+
return snapshot;
|
|
14
|
+
}
|
|
15
|
+
function snapshotUsageTerm(term) {
|
|
16
|
+
const existing = termSnapshots.get(term);
|
|
17
|
+
if (existing != null) return existing;
|
|
18
|
+
let snapshot;
|
|
19
|
+
switch (term.type) {
|
|
20
|
+
case "option":
|
|
21
|
+
snapshot = {
|
|
22
|
+
...term,
|
|
23
|
+
names: Object.freeze([...term.names])
|
|
24
|
+
};
|
|
25
|
+
break;
|
|
26
|
+
case "command":
|
|
27
|
+
snapshot = {
|
|
28
|
+
...term,
|
|
29
|
+
...term.aliases != null && { aliases: Object.freeze([...term.aliases]) },
|
|
30
|
+
...term.hiddenAliases != null && { hiddenAliases: Object.freeze([...term.hiddenAliases]) },
|
|
31
|
+
...term.usageLine != null && typeof term.usageLine !== "function" && { usageLine: snapshotUsage(term.usageLine) }
|
|
32
|
+
};
|
|
33
|
+
break;
|
|
34
|
+
case "optional":
|
|
35
|
+
case "sequence":
|
|
36
|
+
snapshot = {
|
|
37
|
+
type: term.type,
|
|
38
|
+
terms: snapshotUsage(term.terms)
|
|
39
|
+
};
|
|
40
|
+
break;
|
|
41
|
+
case "multiple":
|
|
42
|
+
snapshot = {
|
|
43
|
+
type: "multiple",
|
|
44
|
+
terms: snapshotUsage(term.terms),
|
|
45
|
+
min: term.min,
|
|
46
|
+
...term.acceptsEmpty != null && { acceptsEmpty: term.acceptsEmpty }
|
|
47
|
+
};
|
|
48
|
+
break;
|
|
49
|
+
case "exclusive":
|
|
50
|
+
snapshot = {
|
|
51
|
+
type: "exclusive",
|
|
52
|
+
terms: Object.freeze(term.terms.map(snapshotUsage)),
|
|
53
|
+
...term.acceptsEmpty != null && { acceptsEmpty: term.acceptsEmpty }
|
|
54
|
+
};
|
|
55
|
+
break;
|
|
56
|
+
default: snapshot = { ...term };
|
|
57
|
+
}
|
|
58
|
+
Object.freeze(snapshot);
|
|
59
|
+
termSnapshots.set(term, snapshot);
|
|
60
|
+
return snapshot;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Captures only constructor-owned built-in value documentation.
|
|
64
|
+
* @param parser The built-in value parser's final identity.
|
|
65
|
+
* @param metadata Static formatting facts owned by its constructor.
|
|
66
|
+
* @returns The same parser, with private documentation metadata registered.
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
function captureDocValue(parser, metadata) {
|
|
70
|
+
values.set(parser, Object.freeze({
|
|
71
|
+
...metadata,
|
|
72
|
+
choices: metadata.choices == null ? void 0 : Object.freeze(metadata.choices.slice())
|
|
73
|
+
}));
|
|
74
|
+
return parser;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Captures metadata at the return boundary of a listed built-in constructor.
|
|
78
|
+
* @param parser The supported parser's final identity and static usage.
|
|
79
|
+
* @param metadata Constructor-owned documentation inputs to snapshot.
|
|
80
|
+
* @returns The same parser, with private documentation metadata registered.
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
function captureDocParser(parser, metadata) {
|
|
84
|
+
nodes.set(parser, {
|
|
85
|
+
...metadata,
|
|
86
|
+
brief: metadata.brief == null ? void 0 : require_message.cloneMessage(metadata.brief),
|
|
87
|
+
description: metadata.description == null ? void 0 : require_message.cloneMessage(metadata.description),
|
|
88
|
+
footer: metadata.footer == null ? void 0 : require_message.cloneMessage(metadata.footer),
|
|
89
|
+
defaultMessage: metadata.defaultMessage == null ? void 0 : require_message.cloneMessage(metadata.defaultMessage),
|
|
90
|
+
usageLine: typeof metadata.usageLine === "function" || metadata.usageLine == null ? metadata.usageLine : snapshotUsage(metadata.usageLine),
|
|
91
|
+
children: metadata.children?.slice(),
|
|
92
|
+
aliases: metadata.aliases?.slice(),
|
|
93
|
+
hiddenAliases: metadata.hiddenAliases?.slice(),
|
|
94
|
+
usage: snapshotUsage(parser.usage)
|
|
95
|
+
});
|
|
96
|
+
return parser;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Reads a core-owned node without consulting the parser object.
|
|
100
|
+
* @param parser A parser identity, including an opaque custom parser.
|
|
101
|
+
* @returns Its captured node, or undefined for an unregistered identity.
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
function getDocNode(parser) {
|
|
105
|
+
return nodes.get(parser);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Reads core-owned static value documentation.
|
|
109
|
+
* @param parser A value parser identity.
|
|
110
|
+
* @returns Its captured facts, or undefined for an unregistered identity.
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
function getDocValue(parser) {
|
|
114
|
+
return values.get(parser);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
exports.captureDocParser = captureDocParser;
|
|
119
|
+
exports.captureDocValue = captureDocValue;
|
|
120
|
+
exports.getDocNode = getDocNode;
|
|
121
|
+
exports.getDocValue = getDocValue;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Message } from "../message.cjs";
|
|
2
|
+
import { HiddenVisibility, Usage } from "../usage.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/internal/doc-metadata.d.ts
|
|
5
|
+
/** Static inputs captured by supported constructors. @internal */
|
|
6
|
+
interface DocNodeInput {
|
|
7
|
+
readonly kind: "leaf" | "command" | "or" | "object" | "seq" | "optional" | "multiple" | "default";
|
|
8
|
+
readonly children?: readonly object[];
|
|
9
|
+
readonly name?: string;
|
|
10
|
+
readonly aliases?: readonly string[];
|
|
11
|
+
readonly hiddenAliases?: readonly string[];
|
|
12
|
+
readonly showAliases?: boolean;
|
|
13
|
+
readonly showUsage?: boolean;
|
|
14
|
+
readonly hidden?: HiddenVisibility;
|
|
15
|
+
readonly brief?: Message;
|
|
16
|
+
readonly description?: Message;
|
|
17
|
+
readonly footer?: Message;
|
|
18
|
+
readonly usageLine?: Usage | ((usage: Usage) => Usage);
|
|
19
|
+
readonly valueParser?: object;
|
|
20
|
+
readonly choicesRequested?: boolean;
|
|
21
|
+
readonly boolean?: boolean;
|
|
22
|
+
readonly label?: string;
|
|
23
|
+
readonly min?: number;
|
|
24
|
+
readonly defaultValue?: unknown;
|
|
25
|
+
readonly defaultMessage?: Message;
|
|
26
|
+
}
|
|
27
|
+
/** A constructor snapshot. @internal */
|
|
28
|
+
interface DocNode extends DocNodeInput {
|
|
29
|
+
readonly usage: Usage;
|
|
30
|
+
}
|
|
31
|
+
/** Safe built-in value formatting facts. @internal */
|
|
32
|
+
interface DocValueMetadata {
|
|
33
|
+
readonly kind: "string" | "number" | "bigint";
|
|
34
|
+
/** Already deduplicated by the constructor, preserving both zero signs. */
|
|
35
|
+
readonly choices?: readonly (string | number)[];
|
|
36
|
+
readonly canFormatDefault?: boolean;
|
|
37
|
+
readonly preserveNegativeZero?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Captures only constructor-owned built-in value documentation.
|
|
41
|
+
* @param parser The built-in value parser's final identity.
|
|
42
|
+
* @param metadata Static formatting facts owned by its constructor.
|
|
43
|
+
* @returns The same parser, with private documentation metadata registered.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
declare function captureDocValue<const T extends object>(parser: T, metadata: DocValueMetadata): T;
|
|
47
|
+
/**
|
|
48
|
+
* Captures metadata at the return boundary of a listed built-in constructor.
|
|
49
|
+
* @param parser The supported parser's final identity and static usage.
|
|
50
|
+
* @param metadata Constructor-owned documentation inputs to snapshot.
|
|
51
|
+
* @returns The same parser, with private documentation metadata registered.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
declare function captureDocParser<T extends {
|
|
55
|
+
readonly usage: Usage;
|
|
56
|
+
}>(parser: T, metadata: DocNodeInput): T;
|
|
57
|
+
/**
|
|
58
|
+
* Reads a core-owned node without consulting the parser object.
|
|
59
|
+
* @param parser A parser identity, including an opaque custom parser.
|
|
60
|
+
* @returns Its captured node, or undefined for an unregistered identity.
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
declare function getDocNode(parser: object): DocNode | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Reads core-owned static value documentation.
|
|
66
|
+
* @param parser A value parser identity.
|
|
67
|
+
* @returns Its captured facts, or undefined for an unregistered identity.
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
declare function getDocValue(parser: object): DocValueMetadata | undefined;
|
|
71
|
+
//#endregion
|
|
72
|
+
export { DocNode, DocNodeInput, DocValueMetadata, captureDocParser, captureDocValue, getDocNode, getDocValue };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Message } from "../message.js";
|
|
2
|
+
import { HiddenVisibility, Usage } from "../usage.js";
|
|
3
|
+
|
|
4
|
+
//#region src/internal/doc-metadata.d.ts
|
|
5
|
+
/** Static inputs captured by supported constructors. @internal */
|
|
6
|
+
interface DocNodeInput {
|
|
7
|
+
readonly kind: "leaf" | "command" | "or" | "object" | "seq" | "optional" | "multiple" | "default";
|
|
8
|
+
readonly children?: readonly object[];
|
|
9
|
+
readonly name?: string;
|
|
10
|
+
readonly aliases?: readonly string[];
|
|
11
|
+
readonly hiddenAliases?: readonly string[];
|
|
12
|
+
readonly showAliases?: boolean;
|
|
13
|
+
readonly showUsage?: boolean;
|
|
14
|
+
readonly hidden?: HiddenVisibility;
|
|
15
|
+
readonly brief?: Message;
|
|
16
|
+
readonly description?: Message;
|
|
17
|
+
readonly footer?: Message;
|
|
18
|
+
readonly usageLine?: Usage | ((usage: Usage) => Usage);
|
|
19
|
+
readonly valueParser?: object;
|
|
20
|
+
readonly choicesRequested?: boolean;
|
|
21
|
+
readonly boolean?: boolean;
|
|
22
|
+
readonly label?: string;
|
|
23
|
+
readonly min?: number;
|
|
24
|
+
readonly defaultValue?: unknown;
|
|
25
|
+
readonly defaultMessage?: Message;
|
|
26
|
+
}
|
|
27
|
+
/** A constructor snapshot. @internal */
|
|
28
|
+
interface DocNode extends DocNodeInput {
|
|
29
|
+
readonly usage: Usage;
|
|
30
|
+
}
|
|
31
|
+
/** Safe built-in value formatting facts. @internal */
|
|
32
|
+
interface DocValueMetadata {
|
|
33
|
+
readonly kind: "string" | "number" | "bigint";
|
|
34
|
+
/** Already deduplicated by the constructor, preserving both zero signs. */
|
|
35
|
+
readonly choices?: readonly (string | number)[];
|
|
36
|
+
readonly canFormatDefault?: boolean;
|
|
37
|
+
readonly preserveNegativeZero?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Captures only constructor-owned built-in value documentation.
|
|
41
|
+
* @param parser The built-in value parser's final identity.
|
|
42
|
+
* @param metadata Static formatting facts owned by its constructor.
|
|
43
|
+
* @returns The same parser, with private documentation metadata registered.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
declare function captureDocValue<const T extends object>(parser: T, metadata: DocValueMetadata): T;
|
|
47
|
+
/**
|
|
48
|
+
* Captures metadata at the return boundary of a listed built-in constructor.
|
|
49
|
+
* @param parser The supported parser's final identity and static usage.
|
|
50
|
+
* @param metadata Constructor-owned documentation inputs to snapshot.
|
|
51
|
+
* @returns The same parser, with private documentation metadata registered.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
declare function captureDocParser<T extends {
|
|
55
|
+
readonly usage: Usage;
|
|
56
|
+
}>(parser: T, metadata: DocNodeInput): T;
|
|
57
|
+
/**
|
|
58
|
+
* Reads a core-owned node without consulting the parser object.
|
|
59
|
+
* @param parser A parser identity, including an opaque custom parser.
|
|
60
|
+
* @returns Its captured node, or undefined for an unregistered identity.
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
declare function getDocNode(parser: object): DocNode | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Reads core-owned static value documentation.
|
|
66
|
+
* @param parser A value parser identity.
|
|
67
|
+
* @returns Its captured facts, or undefined for an unregistered identity.
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
declare function getDocValue(parser: object): DocValueMetadata | undefined;
|
|
71
|
+
//#endregion
|
|
72
|
+
export { DocNode, DocNodeInput, DocValueMetadata, captureDocParser, captureDocValue, getDocNode, getDocValue };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { cloneMessage } from "../message.js";
|
|
2
|
+
|
|
3
|
+
//#region src/internal/doc-metadata.ts
|
|
4
|
+
const nodes = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
const values = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
const usageSnapshots = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
const termSnapshots = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
function snapshotUsage(usage) {
|
|
9
|
+
const existing = usageSnapshots.get(usage);
|
|
10
|
+
if (existing != null) return existing;
|
|
11
|
+
const snapshot = Object.freeze(usage.map(snapshotUsageTerm));
|
|
12
|
+
usageSnapshots.set(usage, snapshot);
|
|
13
|
+
return snapshot;
|
|
14
|
+
}
|
|
15
|
+
function snapshotUsageTerm(term) {
|
|
16
|
+
const existing = termSnapshots.get(term);
|
|
17
|
+
if (existing != null) return existing;
|
|
18
|
+
let snapshot;
|
|
19
|
+
switch (term.type) {
|
|
20
|
+
case "option":
|
|
21
|
+
snapshot = {
|
|
22
|
+
...term,
|
|
23
|
+
names: Object.freeze([...term.names])
|
|
24
|
+
};
|
|
25
|
+
break;
|
|
26
|
+
case "command":
|
|
27
|
+
snapshot = {
|
|
28
|
+
...term,
|
|
29
|
+
...term.aliases != null && { aliases: Object.freeze([...term.aliases]) },
|
|
30
|
+
...term.hiddenAliases != null && { hiddenAliases: Object.freeze([...term.hiddenAliases]) },
|
|
31
|
+
...term.usageLine != null && typeof term.usageLine !== "function" && { usageLine: snapshotUsage(term.usageLine) }
|
|
32
|
+
};
|
|
33
|
+
break;
|
|
34
|
+
case "optional":
|
|
35
|
+
case "sequence":
|
|
36
|
+
snapshot = {
|
|
37
|
+
type: term.type,
|
|
38
|
+
terms: snapshotUsage(term.terms)
|
|
39
|
+
};
|
|
40
|
+
break;
|
|
41
|
+
case "multiple":
|
|
42
|
+
snapshot = {
|
|
43
|
+
type: "multiple",
|
|
44
|
+
terms: snapshotUsage(term.terms),
|
|
45
|
+
min: term.min,
|
|
46
|
+
...term.acceptsEmpty != null && { acceptsEmpty: term.acceptsEmpty }
|
|
47
|
+
};
|
|
48
|
+
break;
|
|
49
|
+
case "exclusive":
|
|
50
|
+
snapshot = {
|
|
51
|
+
type: "exclusive",
|
|
52
|
+
terms: Object.freeze(term.terms.map(snapshotUsage)),
|
|
53
|
+
...term.acceptsEmpty != null && { acceptsEmpty: term.acceptsEmpty }
|
|
54
|
+
};
|
|
55
|
+
break;
|
|
56
|
+
default: snapshot = { ...term };
|
|
57
|
+
}
|
|
58
|
+
Object.freeze(snapshot);
|
|
59
|
+
termSnapshots.set(term, snapshot);
|
|
60
|
+
return snapshot;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Captures only constructor-owned built-in value documentation.
|
|
64
|
+
* @param parser The built-in value parser's final identity.
|
|
65
|
+
* @param metadata Static formatting facts owned by its constructor.
|
|
66
|
+
* @returns The same parser, with private documentation metadata registered.
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
function captureDocValue(parser, metadata) {
|
|
70
|
+
values.set(parser, Object.freeze({
|
|
71
|
+
...metadata,
|
|
72
|
+
choices: metadata.choices == null ? void 0 : Object.freeze(metadata.choices.slice())
|
|
73
|
+
}));
|
|
74
|
+
return parser;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Captures metadata at the return boundary of a listed built-in constructor.
|
|
78
|
+
* @param parser The supported parser's final identity and static usage.
|
|
79
|
+
* @param metadata Constructor-owned documentation inputs to snapshot.
|
|
80
|
+
* @returns The same parser, with private documentation metadata registered.
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
function captureDocParser(parser, metadata) {
|
|
84
|
+
nodes.set(parser, {
|
|
85
|
+
...metadata,
|
|
86
|
+
brief: metadata.brief == null ? void 0 : cloneMessage(metadata.brief),
|
|
87
|
+
description: metadata.description == null ? void 0 : cloneMessage(metadata.description),
|
|
88
|
+
footer: metadata.footer == null ? void 0 : cloneMessage(metadata.footer),
|
|
89
|
+
defaultMessage: metadata.defaultMessage == null ? void 0 : cloneMessage(metadata.defaultMessage),
|
|
90
|
+
usageLine: typeof metadata.usageLine === "function" || metadata.usageLine == null ? metadata.usageLine : snapshotUsage(metadata.usageLine),
|
|
91
|
+
children: metadata.children?.slice(),
|
|
92
|
+
aliases: metadata.aliases?.slice(),
|
|
93
|
+
hiddenAliases: metadata.hiddenAliases?.slice(),
|
|
94
|
+
usage: snapshotUsage(parser.usage)
|
|
95
|
+
});
|
|
96
|
+
return parser;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Reads a core-owned node without consulting the parser object.
|
|
100
|
+
* @param parser A parser identity, including an opaque custom parser.
|
|
101
|
+
* @returns Its captured node, or undefined for an unregistered identity.
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
function getDocNode(parser) {
|
|
105
|
+
return nodes.get(parser);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Reads core-owned static value documentation.
|
|
109
|
+
* @param parser A value parser identity.
|
|
110
|
+
* @returns Its captured facts, or undefined for an unregistered identity.
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
function getDocValue(parser) {
|
|
114
|
+
return values.get(parser);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
export { captureDocParser, captureDocValue, getDocNode, getDocValue };
|
package/dist/modifiers.cjs
CHANGED
|
@@ -5,6 +5,7 @@ const require_dependency_runtime = require('./dependency-runtime.cjs');
|
|
|
5
5
|
const require_internal_parser = require('./internal/parser.cjs');
|
|
6
6
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
7
7
|
const require_joined_file_suggestion = require('./internal/joined-file-suggestion.cjs');
|
|
8
|
+
const require_internal_doc_metadata = require('./internal/doc-metadata.cjs');
|
|
8
9
|
const require_empty_input = require('./internal/empty-input.cjs');
|
|
9
10
|
const require_execution_context = require('./execution-context.cjs');
|
|
10
11
|
const require_short_option = require('./short-option.cjs');
|
|
@@ -498,7 +499,10 @@ function optional(parser) {
|
|
|
498
499
|
require_passthrough.defineKnownCompletionLookup(optionalParser, (state) => require_passthrough.getKnownCompletion(parser, deriveOptionalInnerParseState(state, parser)));
|
|
499
500
|
const scopedOptionalParser = require_short_option.scopeParser(optionalParser, require_short_option.combinedOptionScope([parser]));
|
|
500
501
|
require_empty_input.defineEmptyInputFacts(scopedOptionalParser, require_empty_input.optionalLikeFacts(require_empty_input.getEmptyInputFacts(parser), parser.initialState, completesOptionalLikeFallback(parser)));
|
|
501
|
-
return fluent(scopedOptionalParser)
|
|
502
|
+
return require_internal_doc_metadata.captureDocParser(fluent(scopedOptionalParser), {
|
|
503
|
+
kind: "optional",
|
|
504
|
+
children: [parser]
|
|
505
|
+
});
|
|
502
506
|
}
|
|
503
507
|
/**
|
|
504
508
|
* Error type for structured error messages in {@link withDefault} default value callbacks.
|
|
@@ -756,7 +760,12 @@ function withDefault(parser, defaultValue, options) {
|
|
|
756
760
|
require_passthrough.defineKnownCompletionLookup(withDefaultParser, (state) => require_passthrough.getKnownCompletion(parser, deriveOptionalInnerParseState(state, parser)));
|
|
757
761
|
const scopedWithDefaultParser = require_short_option.scopeParser(withDefaultParser, require_short_option.combinedOptionScope([parser]));
|
|
758
762
|
require_empty_input.defineEmptyInputFacts(scopedWithDefaultParser, require_empty_input.optionalLikeFacts(require_empty_input.getEmptyInputFacts(parser), parser.initialState, typeof defaultValue === "function" ? void 0 : completesOptionalLikeFallback(parser)));
|
|
759
|
-
return fluent(scopedWithDefaultParser)
|
|
763
|
+
return require_internal_doc_metadata.captureDocParser(fluent(scopedWithDefaultParser), {
|
|
764
|
+
kind: "default",
|
|
765
|
+
children: [parser],
|
|
766
|
+
defaultValue,
|
|
767
|
+
defaultMessage: options?.message
|
|
768
|
+
});
|
|
760
769
|
}
|
|
761
770
|
/**
|
|
762
771
|
* Creates a parser that transforms the result value of another parser using
|
|
@@ -1798,7 +1807,11 @@ function multiple(parser, options = {}) {
|
|
|
1798
1807
|
})));
|
|
1799
1808
|
const scopedResultParser = require_short_option.scopeParser(resultParser, require_short_option.repeatedOptionScope(parser));
|
|
1800
1809
|
require_empty_input.defineEmptyInputFacts(scopedResultParser, emptyInputFacts);
|
|
1801
|
-
return fluent(scopedResultParser)
|
|
1810
|
+
return require_internal_doc_metadata.captureDocParser(fluent(scopedResultParser), {
|
|
1811
|
+
kind: "multiple",
|
|
1812
|
+
children: [parser],
|
|
1813
|
+
min
|
|
1814
|
+
});
|
|
1802
1815
|
}
|
|
1803
1816
|
/**
|
|
1804
1817
|
* Creates a parser that requires the wrapped parser to consume at least one
|
package/dist/modifiers.js
CHANGED
|
@@ -5,6 +5,7 @@ import { defineForwardedEffectfulSchedulingNodes } from "./dependency-runtime.js
|
|
|
5
5
|
import { defineInheritedAnnotationParser, defineParseLanes, defineSourceBindingOnlyAnnotationCompletionParser, getOwnParseLanes, unmatchedNonCliDependencySourceStateMarker } from "./internal/parser.js";
|
|
6
6
|
import { getDelegatedAnnotationState, hasDelegatedAnnotationCarrier, isAnnotationWrappedInitialState, normalizeDelegatedAnnotationState, normalizeNestedDelegatedAnnotationState } from "./annotation-state.js";
|
|
7
7
|
import { mergeJoinedFileSuggestions } from "./internal/joined-file-suggestion.js";
|
|
8
|
+
import { captureDocParser } from "./internal/doc-metadata.js";
|
|
8
9
|
import { acceptsEmptyInput, defineEmptyInputFacts, getEmptyInputFacts, multipleFacts, optionalLikeFacts, resolveEmptyStepState } from "./internal/empty-input.js";
|
|
9
10
|
import { mergeChildExec, withChildContext, withChildExecPath } from "./execution-context.js";
|
|
10
11
|
import { combinedOptionScope, repeatedOptionScope, scopeParser } from "./short-option.js";
|
|
@@ -498,7 +499,10 @@ function optional(parser) {
|
|
|
498
499
|
defineKnownCompletionLookup(optionalParser, (state) => getKnownCompletion(parser, deriveOptionalInnerParseState(state, parser)));
|
|
499
500
|
const scopedOptionalParser = scopeParser(optionalParser, combinedOptionScope([parser]));
|
|
500
501
|
defineEmptyInputFacts(scopedOptionalParser, optionalLikeFacts(getEmptyInputFacts(parser), parser.initialState, completesOptionalLikeFallback(parser)));
|
|
501
|
-
return fluent(scopedOptionalParser)
|
|
502
|
+
return captureDocParser(fluent(scopedOptionalParser), {
|
|
503
|
+
kind: "optional",
|
|
504
|
+
children: [parser]
|
|
505
|
+
});
|
|
502
506
|
}
|
|
503
507
|
/**
|
|
504
508
|
* Error type for structured error messages in {@link withDefault} default value callbacks.
|
|
@@ -756,7 +760,12 @@ function withDefault(parser, defaultValue, options) {
|
|
|
756
760
|
defineKnownCompletionLookup(withDefaultParser, (state) => getKnownCompletion(parser, deriveOptionalInnerParseState(state, parser)));
|
|
757
761
|
const scopedWithDefaultParser = scopeParser(withDefaultParser, combinedOptionScope([parser]));
|
|
758
762
|
defineEmptyInputFacts(scopedWithDefaultParser, optionalLikeFacts(getEmptyInputFacts(parser), parser.initialState, typeof defaultValue === "function" ? void 0 : completesOptionalLikeFallback(parser)));
|
|
759
|
-
return fluent(scopedWithDefaultParser)
|
|
763
|
+
return captureDocParser(fluent(scopedWithDefaultParser), {
|
|
764
|
+
kind: "default",
|
|
765
|
+
children: [parser],
|
|
766
|
+
defaultValue,
|
|
767
|
+
defaultMessage: options?.message
|
|
768
|
+
});
|
|
760
769
|
}
|
|
761
770
|
/**
|
|
762
771
|
* Creates a parser that transforms the result value of another parser using
|
|
@@ -1798,7 +1807,11 @@ function multiple(parser, options = {}) {
|
|
|
1798
1807
|
})));
|
|
1799
1808
|
const scopedResultParser = scopeParser(resultParser, repeatedOptionScope(parser));
|
|
1800
1809
|
defineEmptyInputFacts(scopedResultParser, emptyInputFacts);
|
|
1801
|
-
return fluent(scopedResultParser)
|
|
1810
|
+
return captureDocParser(fluent(scopedResultParser), {
|
|
1811
|
+
kind: "multiple",
|
|
1812
|
+
children: [parser],
|
|
1813
|
+
min
|
|
1814
|
+
});
|
|
1802
1815
|
}
|
|
1803
1816
|
/**
|
|
1804
1817
|
* Creates a parser that requires the wrapped parser to consume at least one
|
package/dist/primitives.cjs
CHANGED
|
@@ -8,6 +8,7 @@ const require_internal_dependency = require('./internal/dependency.cjs');
|
|
|
8
8
|
const require_dependency_runtime = require('./dependency-runtime.cjs');
|
|
9
9
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
10
10
|
const require_joined_file_suggestion = require('./internal/joined-file-suggestion.cjs');
|
|
11
|
+
const require_internal_doc_metadata = require('./internal/doc-metadata.cjs');
|
|
11
12
|
const require_empty_input = require('./internal/empty-input.cjs');
|
|
12
13
|
const require_execution_context = require('./execution-context.cjs');
|
|
13
14
|
const require_usage_internals = require('./usage-internals.cjs');
|
|
@@ -801,7 +802,13 @@ function option(...args) {
|
|
|
801
802
|
enumerable: false
|
|
802
803
|
});
|
|
803
804
|
else require_empty_input.defineEmptyInputFacts(result, require_empty_input.failingStepFacts(valueParser == null));
|
|
804
|
-
return require_modifiers.fluent(result)
|
|
805
|
+
return require_internal_doc_metadata.captureDocParser(require_modifiers.fluent(result), {
|
|
806
|
+
kind: "leaf",
|
|
807
|
+
description: options.description,
|
|
808
|
+
valueParser,
|
|
809
|
+
choicesRequested: valueParser != null,
|
|
810
|
+
boolean: valueParser == null
|
|
811
|
+
});
|
|
805
812
|
}
|
|
806
813
|
/**
|
|
807
814
|
* Creates a parser for command-line flags that must be explicitly provided.
|
|
@@ -991,7 +998,11 @@ function flag(...args) {
|
|
|
991
998
|
writable: false
|
|
992
999
|
});
|
|
993
1000
|
require_empty_input.defineEmptyInputFacts(result, require_empty_input.failingStepFacts(false));
|
|
994
|
-
return require_modifiers.fluent(result)
|
|
1001
|
+
return require_internal_doc_metadata.captureDocParser(require_modifiers.fluent(result), {
|
|
1002
|
+
kind: "leaf",
|
|
1003
|
+
description: options.description,
|
|
1004
|
+
boolean: true
|
|
1005
|
+
});
|
|
995
1006
|
}
|
|
996
1007
|
function normalizeNegatableFlagNameList(names) {
|
|
997
1008
|
return typeof names === "string" ? [names] : names;
|
|
@@ -1404,7 +1415,12 @@ function argument(valueParser, options = {}) {
|
|
|
1404
1415
|
enumerable: false
|
|
1405
1416
|
});
|
|
1406
1417
|
else require_empty_input.defineEmptyInputFacts(result, require_empty_input.failingStepFacts(false));
|
|
1407
|
-
return require_modifiers.fluent(result)
|
|
1418
|
+
return require_internal_doc_metadata.captureDocParser(require_modifiers.fluent(result), {
|
|
1419
|
+
kind: "leaf",
|
|
1420
|
+
description: options.description,
|
|
1421
|
+
valueParser,
|
|
1422
|
+
choicesRequested: true
|
|
1423
|
+
});
|
|
1408
1424
|
}
|
|
1409
1425
|
function normalizeCommandState(state) {
|
|
1410
1426
|
return require_annotation_state.normalizeInjectedAnnotationState(state);
|
|
@@ -1805,7 +1821,20 @@ function command(name, parser, options = {}) {
|
|
|
1805
1821
|
if (normalizeCommandState(context.state) != null) commandScope.select(context, enteredScope);
|
|
1806
1822
|
});
|
|
1807
1823
|
require_empty_input.defineEmptyInputFacts(scoped, require_empty_input.failingStepFacts(false));
|
|
1808
|
-
return require_modifiers.fluent(scoped)
|
|
1824
|
+
return require_internal_doc_metadata.captureDocParser(require_modifiers.fluent(scoped), {
|
|
1825
|
+
kind: "command",
|
|
1826
|
+
name,
|
|
1827
|
+
aliases,
|
|
1828
|
+
hiddenAliases,
|
|
1829
|
+
showAliases,
|
|
1830
|
+
showUsage,
|
|
1831
|
+
hidden: options.hidden,
|
|
1832
|
+
brief: options.brief,
|
|
1833
|
+
description: options.description,
|
|
1834
|
+
footer: options.footer,
|
|
1835
|
+
usageLine: options.usageLine,
|
|
1836
|
+
children: [parser]
|
|
1837
|
+
});
|
|
1809
1838
|
}
|
|
1810
1839
|
/**
|
|
1811
1840
|
* Creates a parser that collects unrecognized options and passes them through.
|
package/dist/primitives.js
CHANGED
|
@@ -8,6 +8,7 @@ import { getDefaultValuesFunction, getDependencyIds, getSnapshottedDefaultDepend
|
|
|
8
8
|
import { effectfulSchedulingNodesKey, exclusiveSourceScopeKey, includeSourceFailureChain, recordDerivedRawInput, replayDerivedParser, replayDerivedParserAsync, sourceCollectionExpansionKey } from "./dependency-runtime.js";
|
|
9
9
|
import { getWrappedChildParseState, getWrappedChildState, isAnnotationWrappedInitialState, normalizeInjectedAnnotationState } from "./annotation-state.js";
|
|
10
10
|
import { joinedFileSuggestion } from "./internal/joined-file-suggestion.js";
|
|
11
|
+
import { captureDocParser } from "./internal/doc-metadata.js";
|
|
11
12
|
import { UNCHANGED, defineEmptyInputFacts, failingStepFacts } from "./internal/empty-input.js";
|
|
12
13
|
import { mergeChildExec, withChildContext, withChildExecPath } from "./execution-context.js";
|
|
13
14
|
import { extractLeadingCommandNames } from "./usage-internals.js";
|
|
@@ -801,7 +802,13 @@ function option(...args) {
|
|
|
801
802
|
enumerable: false
|
|
802
803
|
});
|
|
803
804
|
else defineEmptyInputFacts(result, failingStepFacts(valueParser == null));
|
|
804
|
-
return fluent(result)
|
|
805
|
+
return captureDocParser(fluent(result), {
|
|
806
|
+
kind: "leaf",
|
|
807
|
+
description: options.description,
|
|
808
|
+
valueParser,
|
|
809
|
+
choicesRequested: valueParser != null,
|
|
810
|
+
boolean: valueParser == null
|
|
811
|
+
});
|
|
805
812
|
}
|
|
806
813
|
/**
|
|
807
814
|
* Creates a parser for command-line flags that must be explicitly provided.
|
|
@@ -991,7 +998,11 @@ function flag(...args) {
|
|
|
991
998
|
writable: false
|
|
992
999
|
});
|
|
993
1000
|
defineEmptyInputFacts(result, failingStepFacts(false));
|
|
994
|
-
return fluent(result)
|
|
1001
|
+
return captureDocParser(fluent(result), {
|
|
1002
|
+
kind: "leaf",
|
|
1003
|
+
description: options.description,
|
|
1004
|
+
boolean: true
|
|
1005
|
+
});
|
|
995
1006
|
}
|
|
996
1007
|
function normalizeNegatableFlagNameList(names) {
|
|
997
1008
|
return typeof names === "string" ? [names] : names;
|
|
@@ -1404,7 +1415,12 @@ function argument(valueParser, options = {}) {
|
|
|
1404
1415
|
enumerable: false
|
|
1405
1416
|
});
|
|
1406
1417
|
else defineEmptyInputFacts(result, failingStepFacts(false));
|
|
1407
|
-
return fluent(result)
|
|
1418
|
+
return captureDocParser(fluent(result), {
|
|
1419
|
+
kind: "leaf",
|
|
1420
|
+
description: options.description,
|
|
1421
|
+
valueParser,
|
|
1422
|
+
choicesRequested: true
|
|
1423
|
+
});
|
|
1408
1424
|
}
|
|
1409
1425
|
function normalizeCommandState(state) {
|
|
1410
1426
|
return normalizeInjectedAnnotationState(state);
|
|
@@ -1805,7 +1821,20 @@ function command(name, parser, options = {}) {
|
|
|
1805
1821
|
if (normalizeCommandState(context.state) != null) commandScope.select(context, enteredScope);
|
|
1806
1822
|
});
|
|
1807
1823
|
defineEmptyInputFacts(scoped, failingStepFacts(false));
|
|
1808
|
-
return fluent(scoped)
|
|
1824
|
+
return captureDocParser(fluent(scoped), {
|
|
1825
|
+
kind: "command",
|
|
1826
|
+
name,
|
|
1827
|
+
aliases,
|
|
1828
|
+
hiddenAliases,
|
|
1829
|
+
showAliases,
|
|
1830
|
+
showUsage,
|
|
1831
|
+
hidden: options.hidden,
|
|
1832
|
+
brief: options.brief,
|
|
1833
|
+
description: options.description,
|
|
1834
|
+
footer: options.footer,
|
|
1835
|
+
usageLine: options.usageLine,
|
|
1836
|
+
children: [parser]
|
|
1837
|
+
});
|
|
1809
1838
|
}
|
|
1810
1839
|
/**
|
|
1811
1840
|
* Creates a parser that collects unrecognized options and passes them through.
|