@kjanat/dreamcli 2.5.0 → 3.0.0-rc.10
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/CHANGELOG.md +344 -1
- package/README.md +9 -2
- package/dist/core/cli/dispatch.d.mts +6 -5
- package/dist/core/cli/dispatch.mjs +205 -1
- package/dist/core/cli/help-links.d.mts +0 -1
- package/dist/core/cli/help-links.mjs +41 -1
- package/dist/core/cli/index.d.mts +185 -19
- package/dist/core/cli/index.mjs +945 -1
- package/dist/core/cli/planner.d.mts +32 -6
- package/dist/core/cli/planner.mjs +300 -1
- package/dist/core/cli/plugin.d.mts +1 -1
- package/dist/core/cli/plugin.mjs +41 -1
- package/dist/core/cli/propagate.d.mts +1 -1
- package/dist/core/cli/propagate.mjs +57 -1
- package/dist/core/cli/root-help.d.mts +18 -3
- package/dist/core/cli/root-help.mjs +226 -6
- package/dist/core/cli/root-surface.d.mts +30 -4
- package/dist/core/cli/root-surface.mjs +28 -1
- package/dist/core/cli/runtime-preflight.d.mts +30 -3
- package/dist/core/cli/runtime-preflight.mjs +169 -1
- package/dist/core/completion/index.d.mts +32 -2
- package/dist/core/completion/index.mjs +90 -1
- package/dist/core/completion/shells/bash.d.mts +0 -1
- package/dist/core/completion/shells/bash.mjs +308 -3
- package/dist/core/completion/shells/fish.d.mts +0 -1
- package/dist/core/completion/shells/fish.mjs +162 -2
- package/dist/core/completion/shells/powershell.d.mts +0 -1
- package/dist/core/completion/shells/powershell.mjs +358 -2
- package/dist/core/completion/shells/shared.d.mts +23 -2
- package/dist/core/completion/shells/shared.mjs +176 -1
- package/dist/core/completion/shells/zsh.d.mts +0 -1
- package/dist/core/completion/shells/zsh.mjs +251 -2
- package/dist/core/config/index.d.mts +2 -3
- package/dist/core/config/index.mjs +246 -1
- package/dist/core/config/package-json.d.mts +27 -4
- package/dist/core/config/package-json.mjs +386 -3
- package/dist/core/errors/index.d.mts +3 -3
- package/dist/core/errors/index.mjs +87 -1
- package/dist/core/execution/index.d.mts +0 -1
- package/dist/core/execution/index.mjs +201 -1
- package/dist/core/help/ansi.d.mts +11 -5
- package/dist/core/help/ansi.mjs +121 -2
- package/dist/core/help/index.d.mts +65 -2
- package/dist/core/help/index.mjs +341 -7
- package/dist/core/help/theme.d.mts +68 -0
- package/dist/core/help/theme.mjs +46 -0
- package/dist/core/json-schema/index.d.mts +15 -2
- package/dist/core/json-schema/index.mjs +536 -12
- package/dist/core/json-schema/meta-descriptions.generated.d.mts +22 -5
- package/dist/core/json-schema/meta-descriptions.generated.mjs +102 -28
- package/dist/core/output/activity.d.mts +0 -1
- package/dist/core/output/activity.mjs +452 -1
- package/dist/core/output/bind.mjs +56 -1
- package/dist/core/output/contracts.d.mts +4 -5
- package/dist/core/output/contracts.mjs +57 -1
- package/dist/core/output/display-value.mjs +32 -1
- package/dist/core/output/index.d.mts +21 -1
- package/dist/core/output/index.mjs +442 -2
- package/dist/core/output/renderers.d.mts +0 -1
- package/dist/core/output/renderers.mjs +46 -1
- package/dist/core/output/writer.mjs +12 -1
- package/dist/core/parse/index.d.mts +54 -7
- package/dist/core/parse/index.mjs +727 -1
- package/dist/core/prompt/index.d.mts +12 -4
- package/dist/core/prompt/index.mjs +348 -6
- package/dist/core/resolve/args.d.mts +1 -1
- package/dist/core/resolve/args.mjs +105 -1
- package/dist/core/resolve/coerce.d.mts +1 -1
- package/dist/core/resolve/coerce.mjs +336 -1
- package/dist/core/resolve/config.mjs +19 -1
- package/dist/core/resolve/contracts.d.mts +9 -4
- package/dist/core/resolve/errors.d.mts +0 -1
- package/dist/core/resolve/errors.mjs +140 -2
- package/dist/core/resolve/flags.d.mts +7 -2
- package/dist/core/resolve/flags.mjs +251 -1
- package/dist/core/resolve/index.d.mts +2 -2
- package/dist/core/resolve/index.mjs +85 -1
- package/dist/core/resolve/property.d.mts +6 -2
- package/dist/core/resolve/property.mjs +53 -1
- package/dist/core/schema/activity.d.mts +31 -11
- package/dist/core/schema/arg.d.mts +92 -13
- package/dist/core/schema/arg.mjs +463 -1
- package/dist/core/schema/command.d.mts +29 -7
- package/dist/core/schema/command.mjs +726 -1
- package/dist/core/schema/flag.d.mts +577 -21
- package/dist/core/schema/flag.mjs +705 -1
- package/dist/core/schema/index.d.mts +5 -2
- package/dist/core/schema/middleware.d.mts +4 -3
- package/dist/core/schema/middleware.mjs +41 -1
- package/dist/core/schema/number-constraints.d.mts +96 -0
- package/dist/core/schema/number-constraints.mjs +60 -0
- package/dist/core/schema/prompt.d.mts +21 -3
- package/dist/core/schema/run.d.mts +24 -5
- package/dist/core/schema/string-constraints.d.mts +97 -0
- package/dist/core/schema/string-constraints.mjs +69 -0
- package/dist/core/schema/value-parsers.d.mts +78 -0
- package/dist/core/schema/value-parsers.mjs +142 -0
- package/dist/core/schema-dsl/runtime.mjs +271 -2
- package/dist/core/schema-dsl/to-json-schema.d.mts +0 -1
- package/dist/core/schema-dsl/to-json-schema.mjs +74 -1
- package/dist/core/testkit/index.d.mts +9 -36
- package/dist/core/testkit/index.mjs +83 -1
- package/dist/index.d.mts +12 -6
- package/dist/index.mjs +22 -1
- package/dist/runtime/adapter.d.mts +38 -2
- package/dist/runtime/adapter.mjs +87 -1
- package/dist/runtime/auto.d.mts +2 -3
- package/dist/runtime/auto.mjs +45 -1
- package/dist/runtime/deno.d.mts +24 -5
- package/dist/runtime/deno.mjs +262 -2
- package/dist/runtime/detect.mjs +45 -1
- package/dist/runtime/index.d.mts +3 -4
- package/dist/runtime/node.d.mts +8 -2
- package/dist/runtime/node.mjs +220 -2
- package/dist/runtime/paths.mjs +48 -1
- package/dist/runtime.d.mts +4 -4
- package/dist/runtime.mjs +6 -1
- package/dist/strings.mjs +22 -1
- package/dist/testkit.d.mts +1 -0
- package/dist/testkit.mjs +5 -1
- package/dist/version.d.mts +7 -3
- package/dist/version.mjs +7 -1
- package/dreamcli.schema.json +36 -7
- package/examples/basic.ts +5 -1
- package/examples/gh/package.json +2 -7
- package/examples/pwsh-demo/package.json +1 -7
- package/examples/pwsh-demo/src/main.test.ts +1 -4
- package/examples/pwsh-demo/src/main.ts +14 -4
- package/examples/transport-launcher.ts +85 -0
- package/package.json +43 -49
- package/dist/runtime/bun.d.mts +0 -28
- package/dist/runtime/bun.mjs +0 -1
- package/dist/runtime/support.d.mts +0 -42
- package/dist/runtime/support.mjs +0 -1
- package/src/core/cli/dispatch.ts +0 -349
- package/src/core/cli/help-links.ts +0 -82
- package/src/core/cli/index.ts +0 -1413
- package/src/core/cli/planner.ts +0 -487
- package/src/core/cli/plugin.ts +0 -117
- package/src/core/cli/propagate.ts +0 -97
- package/src/core/cli/root-help.ts +0 -252
- package/src/core/cli/root-surface.ts +0 -74
- package/src/core/cli/runtime-preflight.ts +0 -438
- package/src/core/completion/index.ts +0 -88
- package/src/core/completion/shells/bash.ts +0 -459
- package/src/core/completion/shells/fish.ts +0 -259
- package/src/core/completion/shells/powershell.ts +0 -439
- package/src/core/completion/shells/shared.ts +0 -283
- package/src/core/completion/shells/zsh.ts +0 -381
- package/src/core/config/index.ts +0 -417
- package/src/core/config/package-json.ts +0 -560
- package/src/core/errors/index.ts +0 -193
- package/src/core/execution/index.ts +0 -268
- package/src/core/help/ansi.ts +0 -144
- package/src/core/help/index.ts +0 -516
- package/src/core/json-schema/index.ts +0 -891
- package/src/core/json-schema/meta-descriptions.generated.ts +0 -185
- package/src/core/output/activity.ts +0 -575
- package/src/core/output/bind.ts +0 -59
- package/src/core/output/contracts.ts +0 -194
- package/src/core/output/display-value.ts +0 -48
- package/src/core/output/index.ts +0 -704
- package/src/core/output/renderers.ts +0 -125
- package/src/core/output/writer.ts +0 -46
- package/src/core/parse/index.ts +0 -681
- package/src/core/prompt/index.ts +0 -583
- package/src/core/resolve/args.ts +0 -144
- package/src/core/resolve/coerce.ts +0 -432
- package/src/core/resolve/config.ts +0 -26
- package/src/core/resolve/contracts.ts +0 -135
- package/src/core/resolve/errors.ts +0 -227
- package/src/core/resolve/flags.ts +0 -255
- package/src/core/resolve/index.ts +0 -108
- package/src/core/resolve/property.ts +0 -99
- package/src/core/schema/activity.ts +0 -240
- package/src/core/schema/arg.ts +0 -719
- package/src/core/schema/command.ts +0 -1498
- package/src/core/schema/flag.ts +0 -801
- package/src/core/schema/index.ts +0 -91
- package/src/core/schema/middleware.ts +0 -171
- package/src/core/schema/prompt.ts +0 -156
- package/src/core/schema/run.ts +0 -198
- package/src/core/schema-dsl/index.ts +0 -109
- package/src/core/schema-dsl/parse.ts +0 -262
- package/src/core/schema-dsl/runtime.ts +0 -609
- package/src/core/schema-dsl/to-json-schema.ts +0 -102
- package/src/core/testkit/index.ts +0 -123
- package/src/index.ts +0 -179
- package/src/runtime/adapter.ts +0 -303
- package/src/runtime/auto.ts +0 -110
- package/src/runtime/bun.ts +0 -55
- package/src/runtime/deno.ts +0 -369
- package/src/runtime/detect.ts +0 -105
- package/src/runtime/index.ts +0 -21
- package/src/runtime/node-builtins.d.ts +0 -27
- package/src/runtime/node.ts +0 -300
- package/src/runtime/paths.ts +0 -64
- package/src/runtime/support.ts +0 -135
- package/src/runtime.ts +0 -31
- package/src/strings.ts +0 -34
- package/src/testkit.ts +0 -25
- package/src/version.ts +0 -20
|
@@ -1 +1,251 @@
|
|
|
1
|
-
import{ValidationError
|
|
1
|
+
import { ValidationError } from "../errors/index.mjs";
|
|
2
|
+
import { resolvePromptConfig } from "../prompt/index.mjs";
|
|
3
|
+
import { coerceValue } from "./coerce.mjs";
|
|
4
|
+
import { isNonEmpty, throwAggregatedErrors } from "./errors.mjs";
|
|
5
|
+
import { resolveConfigPath } from "./config.mjs";
|
|
6
|
+
//#region src/core/resolve/flags.ts
|
|
7
|
+
/**
|
|
8
|
+
* Internal flag resolution helpers.
|
|
9
|
+
*
|
|
10
|
+
* @module dreamcli/core/resolve/flags
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
/** Walk every declared flag through the resolution chain (cli -> env -> config -> prompt -> default), collecting deprecations and throwing aggregated errors. */
|
|
14
|
+
async function resolveFlags(flagSchemas, parsedFlags, env, config, prompter, interactive, deprecations, stat) {
|
|
15
|
+
const resolved = {};
|
|
16
|
+
const errors = [];
|
|
17
|
+
const hardErrorFlags = /* @__PURE__ */ new Set();
|
|
18
|
+
for (const [name, schema] of Object.entries(flagSchemas)) {
|
|
19
|
+
const hasParsedValue = Object.hasOwn(parsedFlags, name);
|
|
20
|
+
const parsedValue = parsedFlags[name];
|
|
21
|
+
if (hasParsedValue && parsedValue !== void 0) {
|
|
22
|
+
if (schema.deprecated !== void 0) deprecations.push({
|
|
23
|
+
kind: "flag",
|
|
24
|
+
name,
|
|
25
|
+
message: schema.deprecated
|
|
26
|
+
});
|
|
27
|
+
resolved[name] = parsedValue;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (schema.envVar !== void 0) {
|
|
31
|
+
const envValue = env[schema.envVar];
|
|
32
|
+
if (envValue !== void 0) {
|
|
33
|
+
const coerced = coerceValue(name, {
|
|
34
|
+
kind: "env",
|
|
35
|
+
envVar: schema.envVar
|
|
36
|
+
}, envValue, schema);
|
|
37
|
+
if (coerced.ok) {
|
|
38
|
+
if (schema.deprecated !== void 0) deprecations.push({
|
|
39
|
+
kind: "flag",
|
|
40
|
+
name,
|
|
41
|
+
message: schema.deprecated
|
|
42
|
+
});
|
|
43
|
+
resolved[name] = coerced.value;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
errors.push(coerced.error);
|
|
47
|
+
hardErrorFlags.add(name);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (schema.configPath !== void 0) {
|
|
52
|
+
const configValue = resolveConfigPath(config, schema.configPath);
|
|
53
|
+
if (configValue !== void 0) {
|
|
54
|
+
const coerced = coerceValue(name, {
|
|
55
|
+
kind: "config",
|
|
56
|
+
configPath: schema.configPath
|
|
57
|
+
}, configValue, schema);
|
|
58
|
+
if (coerced.ok) {
|
|
59
|
+
if (schema.deprecated !== void 0) deprecations.push({
|
|
60
|
+
kind: "flag",
|
|
61
|
+
name,
|
|
62
|
+
message: schema.deprecated
|
|
63
|
+
});
|
|
64
|
+
resolved[name] = coerced.value;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
errors.push(coerced.error);
|
|
68
|
+
hardErrorFlags.add(name);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const interactiveConfigs = interactive !== void 0 ? interactive({ flags: resolved }) : void 0;
|
|
73
|
+
for (const [name, schema] of Object.entries(flagSchemas)) {
|
|
74
|
+
if (Object.hasOwn(resolved, name) || hardErrorFlags.has(name)) continue;
|
|
75
|
+
const interactiveConfig = interactiveConfigs?.[name];
|
|
76
|
+
let effectivePromptConfig;
|
|
77
|
+
if (interactiveConfig !== void 0 && interactiveConfig !== null && interactiveConfig !== false && interactiveConfig !== 0 && interactiveConfig !== "") effectivePromptConfig = interactiveConfig;
|
|
78
|
+
else if (interactiveConfig === false) effectivePromptConfig = void 0;
|
|
79
|
+
else effectivePromptConfig = schema.prompt;
|
|
80
|
+
if (effectivePromptConfig !== void 0 && prompter !== void 0) {
|
|
81
|
+
const promptResult = await resolvePromptValueWithConfig(name, schema, effectivePromptConfig, prompter);
|
|
82
|
+
if (promptResult.ok) {
|
|
83
|
+
if (schema.deprecated !== void 0) deprecations.push({
|
|
84
|
+
kind: "flag",
|
|
85
|
+
name,
|
|
86
|
+
message: schema.deprecated
|
|
87
|
+
});
|
|
88
|
+
resolved[name] = promptResult.value;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (promptResult.error !== void 0) {
|
|
92
|
+
errors.push(promptResult.error);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (schema.defaultValue !== void 0) {
|
|
97
|
+
resolved[name] = schema.defaultValue;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (schema.kind === "array" && schema.presence !== "required") {
|
|
101
|
+
resolved[name] = [];
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (schema.kind === "keyValue" && schema.presence !== "required") {
|
|
105
|
+
resolved[name] = {};
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (schema.presence === "required") {
|
|
109
|
+
const details = {
|
|
110
|
+
flag: name,
|
|
111
|
+
kind: schema.kind
|
|
112
|
+
};
|
|
113
|
+
if (schema.envVar !== void 0) details.envVar = schema.envVar;
|
|
114
|
+
if (schema.configPath !== void 0) details.configPath = schema.configPath;
|
|
115
|
+
errors.push(new ValidationError(`Missing required flag --${name}`, {
|
|
116
|
+
code: "REQUIRED_FLAG",
|
|
117
|
+
details,
|
|
118
|
+
suggest: buildRequiredFlagSuggest(name, schema)
|
|
119
|
+
}));
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
resolved[name] = void 0;
|
|
123
|
+
}
|
|
124
|
+
for (const [name, schema] of Object.entries(flagSchemas)) {
|
|
125
|
+
const value = resolved[name];
|
|
126
|
+
if (schema.kind === "array" && schema.unique && Array.isArray(value)) resolved[name] = [...new Set(value)];
|
|
127
|
+
if (schema.pathChecks !== void 0 && typeof value === "string" && stat !== void 0) {
|
|
128
|
+
const violation = await validatePathChecks(name, value, schema.pathChecks, stat);
|
|
129
|
+
if (violation !== void 0) errors.push(violation);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (isNonEmpty(errors)) throwAggregatedErrors(errors);
|
|
133
|
+
return resolved;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Check a resolved path value against its declared filesystem expectations.
|
|
137
|
+
*
|
|
138
|
+
* @returns `undefined` when the path satisfies the checks, or a
|
|
139
|
+
* {@link ValidationError} with code `'CONSTRAINT_VIOLATED'` otherwise.
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
async function validatePathChecks(flagName, value, checks, stat) {
|
|
143
|
+
const found = await stat(value);
|
|
144
|
+
if (found === null) return new ValidationError(`Path '${value}' for flag --${flagName} does not exist`, {
|
|
145
|
+
code: "CONSTRAINT_VIOLATED",
|
|
146
|
+
details: {
|
|
147
|
+
flag: flagName,
|
|
148
|
+
value,
|
|
149
|
+
constraint: "mustExist"
|
|
150
|
+
},
|
|
151
|
+
suggest: `Provide an existing path for --${flagName}`
|
|
152
|
+
});
|
|
153
|
+
if (checks.type !== void 0 && found !== checks.type) return new ValidationError(`Path '${value}' for flag --${flagName} is a ${found}, expected a ${checks.type}`, {
|
|
154
|
+
code: "CONSTRAINT_VIOLATED",
|
|
155
|
+
details: {
|
|
156
|
+
flag: flagName,
|
|
157
|
+
value,
|
|
158
|
+
constraint: "pathType",
|
|
159
|
+
expected: checks.type
|
|
160
|
+
},
|
|
161
|
+
suggest: `Provide a ${checks.type} path for --${flagName}`
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/** Maps each flag kind to the prompt kinds that produce compatible values. */
|
|
165
|
+
const COMPATIBLE_PROMPT_KINDS = {
|
|
166
|
+
boolean: ["confirm"],
|
|
167
|
+
string: ["input", "select"],
|
|
168
|
+
number: ["input"],
|
|
169
|
+
enum: ["select", "input"],
|
|
170
|
+
array: ["multiselect"],
|
|
171
|
+
custom: [
|
|
172
|
+
"input",
|
|
173
|
+
"select",
|
|
174
|
+
"confirm",
|
|
175
|
+
"multiselect"
|
|
176
|
+
],
|
|
177
|
+
count: [],
|
|
178
|
+
keyValue: []
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Check whether a prompt kind is compatible with the flag's declared kind.
|
|
182
|
+
*
|
|
183
|
+
* @returns `undefined` when compatible, or a {@link ValidationError} with
|
|
184
|
+
* code `'CONSTRAINT_VIOLATED'` and an actionable `suggest` message when not.
|
|
185
|
+
* @internal
|
|
186
|
+
*/
|
|
187
|
+
function validatePromptFlagCompatibility(flagName, flagKind, promptKind) {
|
|
188
|
+
const allowed = COMPATIBLE_PROMPT_KINDS[flagKind];
|
|
189
|
+
if (allowed.includes(promptKind)) return void 0;
|
|
190
|
+
const first = allowed[0];
|
|
191
|
+
if (first === void 0) return new ValidationError(`Prompt kind '${promptKind}' is not compatible with ${flagKind} flag --${flagName}. ${flagKind} flags are not promptable`, {
|
|
192
|
+
code: "CONSTRAINT_VIOLATED",
|
|
193
|
+
details: {
|
|
194
|
+
flag: flagName,
|
|
195
|
+
flagKind,
|
|
196
|
+
promptKind,
|
|
197
|
+
allowed
|
|
198
|
+
},
|
|
199
|
+
suggest: `Remove the prompt config for --${flagName}`
|
|
200
|
+
});
|
|
201
|
+
return new ValidationError(`Prompt kind '${promptKind}' is not compatible with ${flagKind} flag --${flagName}. Use '${first}' instead`, {
|
|
202
|
+
code: "CONSTRAINT_VIOLATED",
|
|
203
|
+
details: {
|
|
204
|
+
flag: flagName,
|
|
205
|
+
flagKind,
|
|
206
|
+
promptKind,
|
|
207
|
+
allowed
|
|
208
|
+
},
|
|
209
|
+
suggest: `Change the prompt to { kind: '${first}' } for --${flagName}`
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Validate prompt/flag compatibility, run the prompt engine, and coerce the result.
|
|
214
|
+
*
|
|
215
|
+
* Returns early with a {@link ValidationError} if the prompt kind is
|
|
216
|
+
* incompatible with the flag kind (checked via {@link COMPATIBLE_PROMPT_KINDS}
|
|
217
|
+
* before the prompter is invoked).
|
|
218
|
+
* @internal
|
|
219
|
+
*/
|
|
220
|
+
async function resolvePromptValueWithConfig(flagName, schema, promptConfig, prompter) {
|
|
221
|
+
const mismatch = validatePromptFlagCompatibility(flagName, schema.kind, promptConfig.kind);
|
|
222
|
+
if (mismatch !== void 0) return {
|
|
223
|
+
ok: false,
|
|
224
|
+
error: mismatch
|
|
225
|
+
};
|
|
226
|
+
const resolvedConfig = resolvePromptConfig(promptConfig, schema.enumValues);
|
|
227
|
+
const result = await prompter.promptOne(resolvedConfig);
|
|
228
|
+
if (!result.answered) return {
|
|
229
|
+
ok: false,
|
|
230
|
+
error: void 0
|
|
231
|
+
};
|
|
232
|
+
if (promptConfig.kind === "input" && promptConfig.default === void 0 && typeof result.value === "string" && result.value.trim() === "") return {
|
|
233
|
+
ok: false,
|
|
234
|
+
error: void 0
|
|
235
|
+
};
|
|
236
|
+
return coerceValue(flagName, { kind: "prompt" }, result.value, schema);
|
|
237
|
+
}
|
|
238
|
+
/** Build a human-readable suggestion listing all available sources for a required flag. @internal */
|
|
239
|
+
function buildRequiredFlagSuggest(name, schema) {
|
|
240
|
+
const sources = [];
|
|
241
|
+
const takesValue = schema.kind !== "boolean" && schema.kind !== "count";
|
|
242
|
+
sources.push(`Provide --${name}${takesValue ? " <value>" : ""}`);
|
|
243
|
+
if (schema.envVar !== void 0) sources.push(`set ${schema.envVar}`);
|
|
244
|
+
if (schema.configPath !== void 0) sources.push(`add ${schema.configPath} to config`);
|
|
245
|
+
if (sources.length <= 1) return sources.join("");
|
|
246
|
+
const rest = sources.slice(0, -1);
|
|
247
|
+
const last = sources.slice(-1).join("");
|
|
248
|
+
return sources.length === 2 ? `${rest.join("")} or ${last}` : `${rest.join(", ")}, or ${last}`;
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
export { COMPATIBLE_PROMPT_KINDS, resolveFlags };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ParseResult } from "../parse/index.mjs";
|
|
2
1
|
import { DeprecationWarning, ResolveOptions, ResolveResult } from "./contracts.mjs";
|
|
3
2
|
import { CommandSchema } from "../schema/command.mjs";
|
|
4
|
-
|
|
3
|
+
import "../schema/index.mjs";
|
|
4
|
+
import { ParseResult } from "../parse/index.mjs";
|
|
5
5
|
//#region src/core/resolve/index.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Resolve parsed values against a command schema.
|
|
@@ -1 +1,85 @@
|
|
|
1
|
-
import{isValidationError
|
|
1
|
+
import { isValidationError } from "../errors/index.mjs";
|
|
2
|
+
import { collectValidationErrors, isNonEmpty, throwAggregatedErrors } from "./errors.mjs";
|
|
3
|
+
import { resolveArgs } from "./args.mjs";
|
|
4
|
+
import { resolveFlags } from "./flags.mjs";
|
|
5
|
+
//#region src/core/resolve/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* Resolution chain: CLI -> env -> config -> prompt -> default.
|
|
8
|
+
*
|
|
9
|
+
* v0.1 implemented: **CLI parsed value -> default value**.
|
|
10
|
+
* v0.2 adds: **env variable resolution** and **config object resolution**
|
|
11
|
+
* between CLI and default.
|
|
12
|
+
* v0.3 adds: **prompt resolution** between config and default.
|
|
13
|
+
*
|
|
14
|
+
* The resolver takes raw {@linkcode ParseResult} (from the parser) and a
|
|
15
|
+
* {@linkcode CommandSchema}, applies the resolution chain, and validates
|
|
16
|
+
* that all required flags/args are present. On success it returns a
|
|
17
|
+
* {@linkcode ResolveResult} with fully resolved values; on failure it throws
|
|
18
|
+
* {@linkcode ValidationError}.
|
|
19
|
+
*
|
|
20
|
+
* @module dreamcli/core/resolve
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Resolve parsed values against a command schema.
|
|
24
|
+
*
|
|
25
|
+
* Low-level API: most applications should rely on `cli().run()`, `.execute()`,
|
|
26
|
+
* or `runCommand()`, which already call {@linkcode resolve} at the right time.
|
|
27
|
+
* Reach for this function when testing precedence rules directly or building
|
|
28
|
+
* custom execution flows around {@linkcode CommandSchema}.
|
|
29
|
+
*
|
|
30
|
+
* Resolution order:
|
|
31
|
+
* 1. CLI parsed value (from {@linkcode ParseResult})
|
|
32
|
+
* 2. Env variable (from {@linkcode ResolveOptions.env}, if flag declares `envVar`)
|
|
33
|
+
* 3. Config value (from {@linkcode ResolveOptions.config}, if flag declares `configPath`)
|
|
34
|
+
* 4. Prompt (from {@linkcode ResolveOptions.prompter}, if flag declares `prompt`)
|
|
35
|
+
* 5. Default value (from schema)
|
|
36
|
+
*
|
|
37
|
+
* After resolution, validates that all required flags and args have
|
|
38
|
+
* a value. Collects **all** validation errors before throwing, so the
|
|
39
|
+
* user sees every missing field at once.
|
|
40
|
+
*
|
|
41
|
+
* @param schema - The command schema defining flags and args
|
|
42
|
+
* @param parsed - Raw parsed values from the parser
|
|
43
|
+
* @param options - External state for the resolution chain
|
|
44
|
+
* @returns Fully resolved flag and arg values
|
|
45
|
+
* @throws {@linkcode ValidationError} if any required flag or arg is missing,
|
|
46
|
+
* or if an env/config value fails coercion
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const parsed = parse(deploy.schema, ['production']);
|
|
51
|
+
* const resolved = await resolve(deploy.schema, parsed, {
|
|
52
|
+
* env: { DEPLOY_REGION: 'eu' },
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
async function resolve(schema, parsed, options) {
|
|
57
|
+
const stdinData = options?.stdinData;
|
|
58
|
+
const env = options?.env ?? {};
|
|
59
|
+
const config = options?.config ?? {};
|
|
60
|
+
const prompter = options?.prompter;
|
|
61
|
+
const deprecations = [];
|
|
62
|
+
let flags = {};
|
|
63
|
+
let args = {};
|
|
64
|
+
const errors = [];
|
|
65
|
+
try {
|
|
66
|
+
flags = await resolveFlags(schema.flags, parsed.flags, env, config, prompter, schema.interactive, deprecations, options?.stat);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (!isValidationError(error)) throw error;
|
|
69
|
+
errors.push(...collectValidationErrors(error));
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
args = resolveArgs(schema.args, parsed.args, stdinData, env, deprecations);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
if (!isValidationError(error)) throw error;
|
|
75
|
+
errors.push(...collectValidationErrors(error));
|
|
76
|
+
}
|
|
77
|
+
if (isNonEmpty(errors)) throwAggregatedErrors(errors);
|
|
78
|
+
return {
|
|
79
|
+
flags,
|
|
80
|
+
args,
|
|
81
|
+
deprecations
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { resolve };
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
import { NumberConstraints } from "../schema/number-constraints.mjs";
|
|
1
2
|
import { ArgSchema } from "../schema/arg.mjs";
|
|
3
|
+
import { StringConstraints } from "../schema/string-constraints.mjs";
|
|
2
4
|
import { FlagSchema } from "../schema/flag.mjs";
|
|
3
|
-
|
|
5
|
+
import "../schema/index.mjs";
|
|
4
6
|
//#region src/core/resolve/property.d.ts
|
|
5
7
|
/** Flag/arg kinds that share a common coercion path. */
|
|
6
|
-
declare const SHARED_PROPERTY_MODEL_KINDS: readonly [
|
|
8
|
+
declare const SHARED_PROPERTY_MODEL_KINDS: readonly ["string", "number", "enum", "custom"];
|
|
7
9
|
/** Union of kind discriminants that participate in shared coercion. */
|
|
8
10
|
type SharedPropertyKind = (typeof SHARED_PROPERTY_MODEL_KINDS)[number];
|
|
9
11
|
/** Minimal coercion-relevant slice of a flag or arg schema, discriminated by kind. */
|
|
10
12
|
type SharedPropertySchema = {
|
|
11
13
|
readonly kind: 'string';
|
|
14
|
+
readonly stringConstraints: StringConstraints | undefined;
|
|
12
15
|
} | {
|
|
13
16
|
readonly kind: 'number';
|
|
17
|
+
readonly numberConstraints: NumberConstraints | undefined;
|
|
14
18
|
} | {
|
|
15
19
|
readonly kind: 'enum';
|
|
16
20
|
readonly enumValues: readonly string[] | undefined;
|
|
@@ -1 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/core/resolve/property.ts
|
|
2
|
+
/** Extract the shared coercion slice from a flag schema, or `undefined` for boolean/array (handled separately). */
|
|
3
|
+
function toSharedFlagPropertySchema(schema) {
|
|
4
|
+
switch (schema.kind) {
|
|
5
|
+
case "string": return {
|
|
6
|
+
kind: "string",
|
|
7
|
+
stringConstraints: schema.stringConstraints
|
|
8
|
+
};
|
|
9
|
+
case "number": return {
|
|
10
|
+
kind: "number",
|
|
11
|
+
numberConstraints: schema.numberConstraints
|
|
12
|
+
};
|
|
13
|
+
case "enum": return {
|
|
14
|
+
kind: "enum",
|
|
15
|
+
enumValues: schema.enumValues
|
|
16
|
+
};
|
|
17
|
+
case "custom": return schema.parseFn === void 0 ? { kind: "custom" } : {
|
|
18
|
+
kind: "custom",
|
|
19
|
+
parseFn: schema.parseFn
|
|
20
|
+
};
|
|
21
|
+
case "boolean":
|
|
22
|
+
case "array":
|
|
23
|
+
case "count":
|
|
24
|
+
case "keyValue": return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Extract the shared coercion slice from an arg schema (all arg kinds are shared). */
|
|
28
|
+
function toSharedArgPropertySchema(schema) {
|
|
29
|
+
switch (schema.kind) {
|
|
30
|
+
case "string": return {
|
|
31
|
+
kind: "string",
|
|
32
|
+
stringConstraints: void 0
|
|
33
|
+
};
|
|
34
|
+
case "number": return {
|
|
35
|
+
kind: "number",
|
|
36
|
+
numberConstraints: schema.numberConstraints
|
|
37
|
+
};
|
|
38
|
+
case "enum": return {
|
|
39
|
+
kind: "enum",
|
|
40
|
+
enumValues: schema.enumValues
|
|
41
|
+
};
|
|
42
|
+
case "custom": {
|
|
43
|
+
if (schema.parseFn === void 0) return { kind: "custom" };
|
|
44
|
+
const parseFn = schema.parseFn;
|
|
45
|
+
return {
|
|
46
|
+
kind: "custom",
|
|
47
|
+
parseFn: (raw) => parseFn(typeof raw === "string" ? raw : String(raw))
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { toSharedArgPropertySchema, toSharedFlagPropertySchema };
|
|
@@ -87,34 +87,54 @@ interface ProgressHandle {
|
|
|
87
87
|
* without polluting stdout/stderr arrays.
|
|
88
88
|
*/
|
|
89
89
|
type ActivityEvent = {
|
|
90
|
-
/** Spinner created and started. */
|
|
90
|
+
/** Spinner created and started. */
|
|
91
|
+
readonly type: 'spinner:start';
|
|
92
|
+
/** Initial spinner text. */
|
|
91
93
|
readonly text: string;
|
|
92
94
|
} | {
|
|
93
|
-
/** Spinner text changed. */
|
|
95
|
+
/** Spinner text changed. */
|
|
96
|
+
readonly type: 'spinner:update';
|
|
97
|
+
/** Updated spinner text. */
|
|
94
98
|
readonly text: string;
|
|
95
99
|
} | {
|
|
96
|
-
/** Spinner completed successfully. */
|
|
100
|
+
/** Spinner completed successfully. */
|
|
101
|
+
readonly type: 'spinner:succeed';
|
|
102
|
+
/** Success message. */
|
|
97
103
|
readonly text: string;
|
|
98
104
|
} | {
|
|
99
|
-
/** Spinner stopped with an error. */
|
|
105
|
+
/** Spinner stopped with an error. */
|
|
106
|
+
readonly type: 'spinner:fail';
|
|
107
|
+
/** Failure message. */
|
|
100
108
|
readonly text: string;
|
|
101
109
|
} | {
|
|
102
|
-
/** Spinner stopped without a final status. */
|
|
110
|
+
/** Spinner stopped without a final status. */
|
|
111
|
+
readonly type: 'spinner:stop';
|
|
103
112
|
} | {
|
|
104
|
-
/** Progress bar created and started. */
|
|
105
|
-
readonly
|
|
113
|
+
/** Progress bar created and started. */
|
|
114
|
+
readonly type: 'progress:start';
|
|
115
|
+
/** Bar label. */
|
|
116
|
+
readonly label: string;
|
|
117
|
+
/** Known total, or `undefined` for indeterminate. */
|
|
106
118
|
readonly total: number | undefined;
|
|
107
119
|
} | {
|
|
108
|
-
/** Progress bar advanced. */
|
|
120
|
+
/** Progress bar advanced. */
|
|
121
|
+
readonly type: 'progress:increment';
|
|
122
|
+
/** Amount advanced. */
|
|
109
123
|
readonly delta: number;
|
|
110
124
|
} | {
|
|
111
|
-
/** Progress bar set to an absolute value. */
|
|
125
|
+
/** Progress bar set to an absolute value. */
|
|
126
|
+
readonly type: 'progress:update';
|
|
127
|
+
/** New absolute value. */
|
|
112
128
|
readonly value: number;
|
|
113
129
|
} | {
|
|
114
|
-
/** Progress bar completed. */
|
|
130
|
+
/** Progress bar completed. */
|
|
131
|
+
readonly type: 'progress:done';
|
|
132
|
+
/** Completion message, if any. */
|
|
115
133
|
readonly text: string | undefined;
|
|
116
134
|
} | {
|
|
117
|
-
/** Progress bar stopped with an error. */
|
|
135
|
+
/** Progress bar stopped with an error. */
|
|
136
|
+
readonly type: 'progress:fail';
|
|
137
|
+
/** Failure message, if any. */
|
|
118
138
|
readonly text: string | undefined;
|
|
119
139
|
};
|
|
120
140
|
/**
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
+
import { NumberConstraints } from "./number-constraints.mjs";
|
|
1
2
|
//#region src/core/schema/arg.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Positional argument schema builder with full type inference.
|
|
4
|
-
*
|
|
5
|
-
* Each factory (`arg.string()`, `arg.number()`, `arg.enum()`, `arg.custom()`) returns an
|
|
6
|
-
* immutable {@linkcode ArgBuilder} whose generic parameter tracks the value type,
|
|
7
|
-
* presence state, and variadic flag through the fluent chain.
|
|
8
|
-
*
|
|
9
|
-
* @module dreamcli/core/schema/arg
|
|
10
|
-
*/
|
|
11
3
|
/** All arg presence states as a runtime array. */
|
|
12
|
-
declare const ARG_PRESENCES: readonly [
|
|
4
|
+
declare const ARG_PRESENCES: readonly ["required", "optional", "defaulted"];
|
|
13
5
|
/**
|
|
14
6
|
* Presence describes whether a positional arg is guaranteed to exist when the
|
|
15
7
|
* action handler runs:
|
|
@@ -29,6 +21,8 @@ interface ArgConfig {
|
|
|
29
21
|
readonly presence: ArgPresence;
|
|
30
22
|
/** Whether this arg consumes remaining positionals. */
|
|
31
23
|
readonly variadic: boolean;
|
|
24
|
+
/** The runtime kind discriminator, mirroring {@link ArgKind}. */
|
|
25
|
+
readonly argKind: ArgKind;
|
|
32
26
|
}
|
|
33
27
|
/**
|
|
34
28
|
* Advanced type helper used by {@linkcode ArgBuilder} modifiers to replace presence.
|
|
@@ -38,6 +32,7 @@ type WithArgPresence<C extends ArgConfig, P extends ArgPresence> = {
|
|
|
38
32
|
readonly valueType: C['valueType'];
|
|
39
33
|
readonly presence: P;
|
|
40
34
|
readonly variadic: C['variadic'];
|
|
35
|
+
readonly argKind: C['argKind'];
|
|
41
36
|
};
|
|
42
37
|
/**
|
|
43
38
|
* Advanced type helper used by {@linkcode ArgBuilder.variadic | ArgBuilder.variadic()}.
|
|
@@ -47,6 +42,7 @@ type WithVariadic<C extends ArgConfig> = {
|
|
|
47
42
|
readonly valueType: C['valueType'];
|
|
48
43
|
readonly presence: C['presence'];
|
|
49
44
|
readonly variadic: true;
|
|
45
|
+
readonly argKind: C['argKind'];
|
|
50
46
|
};
|
|
51
47
|
/**
|
|
52
48
|
* Compute the final value type from config — this is what handlers receive.
|
|
@@ -63,9 +59,9 @@ type ResolvedArgValue<C extends ArgConfig> = C['variadic'] extends true ? C['val
|
|
|
63
59
|
/** Extract the resolved value type from an {@linkcode ArgBuilder}. */
|
|
64
60
|
type InferArg<B> = B extends ArgBuilder<infer C extends ArgConfig> ? ResolvedArgValue<C> : never;
|
|
65
61
|
/** Extract resolved value types from a record of builders. */
|
|
66
|
-
type InferArgs<T extends Record<string, ArgBuilder<ArgConfig>>> = { [K in keyof T]: InferArg<T[K]
|
|
62
|
+
type InferArgs<T extends Record<string, ArgBuilder<ArgConfig>>> = { [K in keyof T]: InferArg<T[K]>; };
|
|
67
63
|
/** All arg kind discriminators as a runtime array. */
|
|
68
|
-
declare const ARG_KINDS: readonly [
|
|
64
|
+
declare const ARG_KINDS: readonly ["string", "number", "enum", "custom"];
|
|
69
65
|
/** Discriminator for the kind of value an arg accepts. */
|
|
70
66
|
type ArgKind = (typeof ARG_KINDS)[number];
|
|
71
67
|
/** Custom parse function for `arg.custom()`. */
|
|
@@ -102,6 +98,13 @@ interface ArgSchema {
|
|
|
102
98
|
readonly envVar: string | undefined;
|
|
103
99
|
/** Allowed literal values when `kind === 'enum'`. */
|
|
104
100
|
readonly enumValues: readonly string[] | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Numeric constraints when `kind === 'number'` (`undefined` otherwise).
|
|
103
|
+
*
|
|
104
|
+
* Enforced at the parse and resolution boundaries. `finite` defaults to
|
|
105
|
+
* `true`, so `Infinity` is rejected even when no constraints object is set.
|
|
106
|
+
*/
|
|
107
|
+
readonly numberConstraints: NumberConstraints | undefined;
|
|
105
108
|
/** Custom parse function (only when `kind === 'custom'`). */
|
|
106
109
|
readonly parseFn: ArgParseFn<unknown> | undefined;
|
|
107
110
|
/**
|
|
@@ -376,6 +379,71 @@ declare class ArgBuilder<C extends ArgConfig> {
|
|
|
376
379
|
* ```
|
|
377
380
|
*/
|
|
378
381
|
deprecated(message?: string): ArgBuilder<C>;
|
|
382
|
+
/**
|
|
383
|
+
* Require an integer value. Composes with other numeric constraints.
|
|
384
|
+
*
|
|
385
|
+
* @param value - Whether to require an integer.
|
|
386
|
+
* @defaultValue `true`
|
|
387
|
+
* @returns The builder (for chaining).
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```ts
|
|
391
|
+
* arg.number().int() // rejects 3.7, accepts 3
|
|
392
|
+
* arg.number({ int: true }).int(false) // re-allows non-integers
|
|
393
|
+
* ```
|
|
394
|
+
*/
|
|
395
|
+
int(this: ArgBuilder<C & {
|
|
396
|
+
readonly argKind: 'number';
|
|
397
|
+
}>, value?: boolean): ArgBuilder<C>;
|
|
398
|
+
/**
|
|
399
|
+
* Set an inclusive lower bound. Composes with other numeric constraints;
|
|
400
|
+
* a later call overrides an earlier `min` (including one from the options
|
|
401
|
+
* object).
|
|
402
|
+
*
|
|
403
|
+
* @param value - Inclusive minimum.
|
|
404
|
+
* @returns The builder (for chaining).
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```ts
|
|
408
|
+
* arg.number().min(0) // rejects -1, accepts 0
|
|
409
|
+
* arg.number({ min: 0 }).min(5) // effective min is 5
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
412
|
+
min(this: ArgBuilder<C & {
|
|
413
|
+
readonly argKind: 'number';
|
|
414
|
+
}>, value: number): ArgBuilder<C>;
|
|
415
|
+
/**
|
|
416
|
+
* Set an inclusive upper bound. Composes with other numeric constraints;
|
|
417
|
+
* a later call overrides an earlier `max`.
|
|
418
|
+
*
|
|
419
|
+
* @param value - Inclusive maximum.
|
|
420
|
+
* @returns The builder (for chaining).
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```ts
|
|
424
|
+
* arg.number().max(100) // rejects 101, accepts 100
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
max(this: ArgBuilder<C & {
|
|
428
|
+
readonly argKind: 'number';
|
|
429
|
+
}>, value: number): ArgBuilder<C>;
|
|
430
|
+
/**
|
|
431
|
+
* Require (or, with `false`, allow) a finite value. Finiteness is enforced
|
|
432
|
+
* by default, so this is mainly used as `.finite(false)` to re-allow
|
|
433
|
+
* `Infinity` / `-Infinity`.
|
|
434
|
+
*
|
|
435
|
+
* @param allow - Whether to require a finite value.
|
|
436
|
+
* @defaultValue `true`
|
|
437
|
+
* @returns The builder (for chaining).
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```ts
|
|
441
|
+
* arg.number().finite(false) // accepts Infinity
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
finite(this: ArgBuilder<C & {
|
|
445
|
+
readonly argKind: 'number';
|
|
446
|
+
}>, allow?: boolean): ArgBuilder<C>;
|
|
379
447
|
}
|
|
380
448
|
/**
|
|
381
449
|
* Arg factory functions — the public API for creating positional arguments.
|
|
@@ -439,6 +507,7 @@ interface ArgFactory {
|
|
|
439
507
|
readonly valueType: string;
|
|
440
508
|
readonly presence: 'required';
|
|
441
509
|
readonly variadic: false;
|
|
510
|
+
readonly argKind: 'string';
|
|
442
511
|
}>;
|
|
443
512
|
/**
|
|
444
513
|
* Number-valued positional argument. Required by default.
|
|
@@ -460,12 +529,20 @@ interface ArgFactory {
|
|
|
460
529
|
* // $ mycli serve → 3000
|
|
461
530
|
* ```
|
|
462
531
|
*
|
|
532
|
+
* Constraints are enforced at the parse and resolution boundaries and also
|
|
533
|
+
* compose via chained methods (`.int()`, `.min()`, `.max()`, `.finite()`),
|
|
534
|
+
* which override values set here. The resolved value type stays `number`.
|
|
535
|
+
*
|
|
536
|
+
* @param constraints - Optional numeric constraints. `finite` defaults to
|
|
537
|
+
* `true`, so `Infinity` / `-Infinity` are rejected unless `finite: false`.
|
|
538
|
+
* @defaultValue `undefined` (finite-only, no bounds, non-integer allowed)
|
|
463
539
|
* @returns A required number {@link ArgBuilder}.
|
|
464
540
|
*/
|
|
465
|
-
number(): ArgBuilder<{
|
|
541
|
+
number(constraints?: NumberConstraints): ArgBuilder<{
|
|
466
542
|
readonly valueType: number;
|
|
467
543
|
readonly presence: 'required';
|
|
468
544
|
readonly variadic: false;
|
|
545
|
+
readonly argKind: 'number';
|
|
469
546
|
}>;
|
|
470
547
|
/**
|
|
471
548
|
* Enum-valued positional argument. Required by default.
|
|
@@ -494,6 +571,7 @@ interface ArgFactory {
|
|
|
494
571
|
readonly valueType: T[number];
|
|
495
572
|
readonly presence: 'required';
|
|
496
573
|
readonly variadic: false;
|
|
574
|
+
readonly argKind: 'enum';
|
|
497
575
|
}>;
|
|
498
576
|
/**
|
|
499
577
|
* Custom-parsed positional argument. Required by default.
|
|
@@ -524,6 +602,7 @@ interface ArgFactory {
|
|
|
524
602
|
readonly valueType: T;
|
|
525
603
|
readonly presence: 'required';
|
|
526
604
|
readonly variadic: false;
|
|
605
|
+
readonly argKind: 'custom';
|
|
527
606
|
}>;
|
|
528
607
|
}
|
|
529
608
|
/**
|