@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,11 +1,520 @@
|
|
|
1
|
-
import{getFlagAliasNames
|
|
2
|
-
|
|
1
|
+
import { getFlagAliasNames } from "../schema/flag.mjs";
|
|
2
|
+
import { parseSchema } from "../schema-dsl/runtime.mjs";
|
|
3
|
+
import { nodeToJsonSchema } from "../schema-dsl/to-json-schema.mjs";
|
|
4
|
+
import { definitionMetaSchemaDescriptions } from "./meta-descriptions.generated.mjs";
|
|
5
|
+
//#region src/core/json-schema/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* Apply defaults to optional {@link JsonSchemaOptions}.
|
|
8
|
+
*
|
|
9
|
+
* @param options - User-supplied schema generation options, or `undefined` for all defaults.
|
|
10
|
+
* @returns Fully resolved options with defaults applied.
|
|
11
|
+
*/
|
|
12
|
+
function resolveOptions(options) {
|
|
13
|
+
return {
|
|
14
|
+
includeHidden: options?.includeHidden ?? true,
|
|
15
|
+
includePrompts: options?.includePrompts ?? true
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* `$schema` URL for definition documents.
|
|
20
|
+
*
|
|
21
|
+
* Resolves via the actual file path on the CDN (`dreamcli.schema.json`).
|
|
22
|
+
* For offline or local-first workflows, use
|
|
23
|
+
* `./node_modules/@kjanat/dreamcli/dreamcli.schema.json`.
|
|
24
|
+
*/
|
|
25
|
+
const DEFINITION_SCHEMA_URL = "https://cdn.jsdelivr.net/npm/@kjanat/dreamcli/dreamcli.schema.json";
|
|
26
|
+
/** Meta-schema URL for JSON Schema draft 2020-12 (input validation). */
|
|
27
|
+
const JSON_SCHEMA_DRAFT = "https://json-schema.org/draft/2020-12/schema";
|
|
28
|
+
function isRecord(value) {
|
|
29
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generate a definition metadata document describing the CLI's structure.
|
|
33
|
+
*
|
|
34
|
+
* Walks the full command tree and produces a plain JSON-serializable object
|
|
35
|
+
* representing all commands, subcommands, flags, args, and metadata.
|
|
36
|
+
* Non-serializable runtime values (parse functions, middleware handlers,
|
|
37
|
+
* interactive resolvers) are omitted.
|
|
38
|
+
*
|
|
39
|
+
* @param schema - The CLI schema from `CLIBuilder.schema`.
|
|
40
|
+
* @param options - Generation options.
|
|
41
|
+
* @returns A plain object suitable for `JSON.stringify()`.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const app = cli('myapp').version('1.0.0').command(deploy);
|
|
46
|
+
* const definition = generateSchema(app.schema);
|
|
47
|
+
* writeFileSync('cli-schema.json', JSON.stringify(definition, null, 2));
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
function generateSchema(schema, options) {
|
|
51
|
+
const opts = resolveOptions(options);
|
|
52
|
+
const result = {
|
|
53
|
+
$schema: DEFINITION_SCHEMA_URL,
|
|
54
|
+
name: schema.name
|
|
55
|
+
};
|
|
56
|
+
if (schema.version !== void 0) result.version = schema.version;
|
|
57
|
+
if (schema.description !== void 0) result.description = schema.description;
|
|
58
|
+
if (schema.defaultCommand !== void 0 && (opts.includeHidden || !schema.defaultCommand.schema.hidden)) result.defaultCommand = serializeCommand(schema.defaultCommand.schema, opts);
|
|
59
|
+
result.commands = schema.commands.filter((cmd) => opts.includeHidden || !cmd.schema.hidden).map((cmd) => serializeCommand(cmd.schema, opts));
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Generate the definition metadata document for a single command.
|
|
64
|
+
*
|
|
65
|
+
* The per-command counterpart of {@link generateSchema}: the same
|
|
66
|
+
* JSON-serializable shape as one entry of its `commands` array (flags, args,
|
|
67
|
+
* subcommands, examples). Powers `--help` in `--json` mode and is useful for
|
|
68
|
+
* embedding one command's definition into custom tooling.
|
|
69
|
+
*
|
|
70
|
+
* @param schema - The command schema to serialize.
|
|
71
|
+
* @param options - Generation options.
|
|
72
|
+
* @returns A plain object suitable for `JSON.stringify()`.
|
|
73
|
+
*/
|
|
74
|
+
function generateCommandSchema(schema, options) {
|
|
75
|
+
return serializeCommand(schema, resolveOptions(options));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Serialize a single {@link CommandSchema} into a plain object.
|
|
79
|
+
*
|
|
80
|
+
* @param schema - The command schema to serialize.
|
|
81
|
+
* @param opts - Resolved generation options (hidden/prompt inclusion).
|
|
82
|
+
* @returns JSON-serializable object representing the command.
|
|
83
|
+
*/
|
|
84
|
+
function serializeCommand(schema, opts) {
|
|
85
|
+
const result = { name: schema.name };
|
|
86
|
+
if (schema.description !== void 0) result.description = schema.description;
|
|
87
|
+
if (schema.aliases.length > 0) result.aliases = [...schema.aliases];
|
|
88
|
+
if (schema.hidden) result.hidden = true;
|
|
89
|
+
if (schema.examples.length > 0) result.examples = schema.examples.map(serializeExample);
|
|
90
|
+
const flags = {};
|
|
91
|
+
for (const [name, flagDef] of Object.entries(schema.flags)) flags[name] = serializeFlag(flagDef, opts);
|
|
92
|
+
result.flags = flags;
|
|
93
|
+
result.args = schema.args.map(serializeArgEntry);
|
|
94
|
+
result.commands = schema.commands.filter((cmd) => opts.includeHidden || !cmd.hidden).map((cmd) => serializeCommand(cmd, opts));
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Serialize a {@link FlagSchema} into a plain object.
|
|
99
|
+
*
|
|
100
|
+
* @param schema - The flag schema to serialize.
|
|
101
|
+
* @param opts - Resolved generation options (prompt inclusion).
|
|
102
|
+
* @returns JSON-serializable object representing the flag.
|
|
103
|
+
*/
|
|
104
|
+
function serializeFlag(schema, opts) {
|
|
105
|
+
const result = {
|
|
106
|
+
kind: schema.kind,
|
|
107
|
+
presence: schema.presence
|
|
108
|
+
};
|
|
109
|
+
if (schema.presence === "defaulted" && isJsonSerializable(schema.defaultValue)) result.defaultValue = schema.defaultValue;
|
|
110
|
+
const visibleAliases = getFlagAliasNames(schema);
|
|
111
|
+
if (visibleAliases.length > 0) result.aliases = [...visibleAliases];
|
|
112
|
+
if (schema.envVar !== void 0) result.envVar = schema.envVar;
|
|
113
|
+
if (schema.configPath !== void 0) result.configPath = schema.configPath;
|
|
114
|
+
if (schema.description !== void 0) result.description = schema.description;
|
|
115
|
+
if (schema.enumValues !== void 0) result.enumValues = [...schema.enumValues];
|
|
116
|
+
if (schema.elementSchema !== void 0) result.elementSchema = serializeFlag(schema.elementSchema, opts);
|
|
117
|
+
if (opts.includePrompts && schema.prompt !== void 0) result.prompt = serializePrompt(schema.prompt);
|
|
118
|
+
if (schema.deprecated !== void 0) result.deprecated = schema.deprecated;
|
|
119
|
+
if (schema.propagate) result.propagate = true;
|
|
120
|
+
if (schema.negation !== void 0) {
|
|
121
|
+
const negation = {};
|
|
122
|
+
if (schema.negation.alias !== void 0) negation.alias = schema.negation.alias;
|
|
123
|
+
if (schema.negation.hidden) negation.hidden = true;
|
|
124
|
+
result.negation = negation;
|
|
125
|
+
}
|
|
126
|
+
if (schema.duplicates !== "last") result.duplicates = schema.duplicates;
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Serialize a {@link CommandArgEntry} into a plain object.
|
|
131
|
+
*
|
|
132
|
+
* @param entry - The positional arg entry (name + {@link ArgSchema}).
|
|
133
|
+
* @returns JSON-serializable object representing the arg.
|
|
134
|
+
*/
|
|
135
|
+
function serializeArgEntry(entry) {
|
|
136
|
+
const { name, schema } = entry;
|
|
137
|
+
const result = {
|
|
138
|
+
name,
|
|
139
|
+
kind: schema.kind,
|
|
140
|
+
presence: schema.presence
|
|
141
|
+
};
|
|
142
|
+
if (schema.variadic) result.variadic = true;
|
|
143
|
+
if (schema.stdinMode) result.stdinMode = true;
|
|
144
|
+
if (schema.presence === "defaulted" && isJsonSerializable(schema.defaultValue)) result.defaultValue = schema.defaultValue;
|
|
145
|
+
if (schema.description !== void 0) result.description = schema.description;
|
|
146
|
+
if (schema.envVar !== void 0) result.envVar = schema.envVar;
|
|
147
|
+
if (schema.enumValues !== void 0) result.enumValues = [...schema.enumValues];
|
|
148
|
+
if (schema.deprecated !== void 0) result.deprecated = schema.deprecated;
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Serialize a {@link PromptConfig} into a plain object.
|
|
153
|
+
*
|
|
154
|
+
* @param prompt - The prompt configuration to serialize.
|
|
155
|
+
* @returns JSON-serializable object representing the prompt.
|
|
156
|
+
*/
|
|
157
|
+
function serializePrompt(prompt) {
|
|
158
|
+
const result = {
|
|
159
|
+
kind: prompt.kind,
|
|
160
|
+
message: prompt.message
|
|
161
|
+
};
|
|
162
|
+
switch (prompt.kind) {
|
|
163
|
+
case "input":
|
|
164
|
+
if (prompt.placeholder !== void 0) result.placeholder = prompt.placeholder;
|
|
165
|
+
break;
|
|
166
|
+
case "select":
|
|
167
|
+
if (prompt.choices !== void 0) result.choices = prompt.choices.map(serializeChoice);
|
|
168
|
+
break;
|
|
169
|
+
case "multiselect":
|
|
170
|
+
if (prompt.choices !== void 0) result.choices = prompt.choices.map(serializeChoice);
|
|
171
|
+
if (prompt.min !== void 0) result.min = prompt.min;
|
|
172
|
+
if (prompt.max !== void 0) result.max = prompt.max;
|
|
173
|
+
break;
|
|
174
|
+
case "confirm": break;
|
|
175
|
+
}
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Serialize a {@link SelectChoice} into a plain object.
|
|
180
|
+
*
|
|
181
|
+
* @param choice - The select/multiselect choice to serialize.
|
|
182
|
+
* @returns JSON-serializable object with value, optional label and description.
|
|
183
|
+
*/
|
|
184
|
+
function serializeChoice(choice) {
|
|
185
|
+
const result = { value: choice.value };
|
|
186
|
+
if (choice.label !== void 0) result.label = choice.label;
|
|
187
|
+
if (choice.description !== void 0) result.description = choice.description;
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Serialize a {@link CommandExample} into a plain object.
|
|
192
|
+
*
|
|
193
|
+
* @param example - The example to serialize.
|
|
194
|
+
* @returns JSON-serializable object with command and optional description.
|
|
195
|
+
*/
|
|
196
|
+
function serializeExample(example) {
|
|
197
|
+
const result = { command: example.command };
|
|
198
|
+
if (example.description !== void 0) result.description = example.description;
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Generate a JSON Schema (draft 2020-12) for validating CLI input as JSON.
|
|
203
|
+
*
|
|
204
|
+
* Accepts either a full {@link CLISchema} (producing a discriminated union
|
|
205
|
+
* across all commands) or a single {@link CommandSchema} (producing a flat
|
|
206
|
+
* object schema for that command's flags and args).
|
|
207
|
+
*
|
|
208
|
+
* **Single command** — produces an object schema where flag/arg names are
|
|
209
|
+
* properties with appropriate JSON Schema types.
|
|
210
|
+
*
|
|
211
|
+
* **Multi-command CLI** — produces a `oneOf` discriminated union with a
|
|
212
|
+
* `command` property identifying each branch. Nested subcommands use
|
|
213
|
+
* dot-delimited paths (e.g. `"deploy.rollback"`).
|
|
214
|
+
*
|
|
215
|
+
* Only commands with action handlers are included (group commands without
|
|
216
|
+
* actions are not directly invocable and are skipped).
|
|
217
|
+
*
|
|
218
|
+
* @param schema - A CLI schema or a single command schema.
|
|
219
|
+
* @param options - Generation options.
|
|
220
|
+
* @returns A JSON Schema object suitable for `JSON.stringify()`.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* // Validate a config file against the CLI's input shape
|
|
225
|
+
* const inputSchema = generateInputSchema(app.schema);
|
|
226
|
+
* writeFileSync('input-schema.json', JSON.stringify(inputSchema, null, 2));
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
function generateInputSchema(schema, options) {
|
|
230
|
+
const opts = resolveOptions(options);
|
|
231
|
+
if (isCommandSchema(schema)) return {
|
|
232
|
+
$schema: JSON_SCHEMA_DRAFT,
|
|
233
|
+
...commandToInputSchema(schema)
|
|
234
|
+
};
|
|
235
|
+
const branches = [];
|
|
236
|
+
for (const cmd of schema.commands) {
|
|
237
|
+
if (!opts.includeHidden && cmd.schema.hidden) continue;
|
|
238
|
+
collectInputBranches(cmd.schema, "", branches, opts);
|
|
239
|
+
}
|
|
240
|
+
if (branches.length === 1) {
|
|
241
|
+
const branch = stripCommandDiscriminator(branches[0] ?? {});
|
|
242
|
+
return {
|
|
243
|
+
$schema: JSON_SCHEMA_DRAFT,
|
|
244
|
+
...branch
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
if (branches.length > 0) {
|
|
248
|
+
const defaultBranchName = schema.defaultCommand !== void 0 && (opts.includeHidden || !schema.defaultCommand.schema.hidden) ? schema.defaultCommand.schema.name : void 0;
|
|
249
|
+
const normalizedBranches = defaultBranchName !== void 0 ? branches.map((branch) => getBranchCommandDiscriminator(branch) === defaultBranchName ? stripCommandDiscriminator(branch) : branch) : branches;
|
|
250
|
+
return {
|
|
251
|
+
$schema: JSON_SCHEMA_DRAFT,
|
|
252
|
+
oneOf: normalizedBranches
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
$schema: JSON_SCHEMA_DRAFT,
|
|
257
|
+
type: "object"
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Discriminate between CLISchema and CommandSchema at runtime.
|
|
262
|
+
*
|
|
263
|
+
* Use a command-only field combination rather than a single shape check:
|
|
264
|
+
* command schemas always carry flags, args, middleware, and hasAction, while
|
|
265
|
+
* the CLI root schema does not expose that execution surface.
|
|
266
|
+
*/
|
|
267
|
+
function isCommandSchema(schema) {
|
|
268
|
+
return "flags" in schema && "args" in schema && "middleware" in schema && "hasAction" in schema;
|
|
269
|
+
}
|
|
270
|
+
/** Recursively collect input schema branches for all invocable commands. */
|
|
271
|
+
function collectInputBranches(schema, prefix, branches, opts) {
|
|
272
|
+
const path = prefix ? `${prefix}.${schema.name}` : schema.name;
|
|
273
|
+
if (schema.hasAction) branches.push(commandToInputSchema(schema, path));
|
|
274
|
+
for (const sub of schema.commands) {
|
|
275
|
+
if (!opts.includeHidden && sub.hidden) continue;
|
|
276
|
+
collectInputBranches(sub, path, branches, opts);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Create a JSON Schema object for a single command's flags + args.
|
|
281
|
+
*
|
|
282
|
+
* When `commandPath` is provided, a `command` const discriminator property
|
|
283
|
+
* is added and required (used in multi-command oneOf schemas).
|
|
284
|
+
*/
|
|
285
|
+
function commandToInputSchema(schema, commandPath) {
|
|
286
|
+
const properties = {};
|
|
287
|
+
const required = [];
|
|
288
|
+
if (commandPath !== void 0) {
|
|
289
|
+
properties.command = { const: commandPath };
|
|
290
|
+
required.push("command");
|
|
291
|
+
}
|
|
292
|
+
for (const [name, flagDef] of Object.entries(schema.flags)) {
|
|
293
|
+
properties[name] = flagToJsonSchemaType(flagDef);
|
|
294
|
+
if (flagDef.presence === "required") required.push(name);
|
|
295
|
+
}
|
|
296
|
+
for (const entry of schema.args) {
|
|
297
|
+
properties[entry.name] = argToJsonSchemaType(entry.schema);
|
|
298
|
+
if (entry.schema.presence === "required") required.push(entry.name);
|
|
299
|
+
}
|
|
300
|
+
const result = {
|
|
301
|
+
type: "object",
|
|
302
|
+
properties,
|
|
303
|
+
additionalProperties: false
|
|
304
|
+
};
|
|
305
|
+
if (required.length > 0) result.required = required;
|
|
306
|
+
return result;
|
|
307
|
+
}
|
|
308
|
+
/** @internal */
|
|
309
|
+
function stripCommandDiscriminator(branch) {
|
|
310
|
+
const propertiesValue = branch.properties;
|
|
311
|
+
const requiredValue = branch.required;
|
|
312
|
+
const properties = isRecord(propertiesValue) ? { ...propertiesValue } : void 0;
|
|
313
|
+
const required = Array.isArray(requiredValue) ? requiredValue.filter((value) => typeof value === "string") : void 0;
|
|
314
|
+
if (properties !== void 0) delete properties.command;
|
|
315
|
+
const cleanedRequired = required?.filter((value) => value !== "command");
|
|
316
|
+
const result = { ...branch };
|
|
317
|
+
if (properties !== void 0) result.properties = properties;
|
|
318
|
+
if (cleanedRequired !== void 0 && cleanedRequired.length > 0) result.required = cleanedRequired;
|
|
319
|
+
else delete result.required;
|
|
320
|
+
return result;
|
|
321
|
+
}
|
|
322
|
+
function getBranchCommandDiscriminator(branch) {
|
|
323
|
+
const propertiesValue = branch.properties;
|
|
324
|
+
if (!isRecord(propertiesValue)) return;
|
|
325
|
+
const commandValue = propertiesValue.command;
|
|
326
|
+
return isRecord(commandValue) && typeof commandValue.const === "string" ? commandValue.const : void 0;
|
|
327
|
+
}
|
|
328
|
+
function flagToJsonSchemaType(schema) {
|
|
329
|
+
const result = {};
|
|
330
|
+
switch (schema.kind) {
|
|
331
|
+
case "string": {
|
|
332
|
+
result.type = "string";
|
|
333
|
+
const constraints = schema.stringConstraints;
|
|
334
|
+
const minLength = constraints?.nonEmpty === true ? Math.max(constraints.minLength ?? 1, 1) : constraints?.minLength;
|
|
335
|
+
if (minLength !== void 0) result.minLength = minLength;
|
|
336
|
+
if (constraints?.maxLength !== void 0) result.maxLength = constraints.maxLength;
|
|
337
|
+
if (constraints?.pattern !== void 0) result.pattern = constraints.pattern.source;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
case "number": {
|
|
341
|
+
const constraints = schema.numberConstraints;
|
|
342
|
+
result.type = constraints?.int === true ? "integer" : "number";
|
|
343
|
+
if (constraints?.min !== void 0) result.minimum = constraints.min;
|
|
344
|
+
if (constraints?.max !== void 0) result.maximum = constraints.max;
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
case "boolean":
|
|
348
|
+
result.type = "boolean";
|
|
349
|
+
break;
|
|
350
|
+
case "enum":
|
|
351
|
+
result.type = "string";
|
|
352
|
+
if (schema.enumValues !== void 0) result.enum = [...schema.enumValues];
|
|
353
|
+
break;
|
|
354
|
+
case "array":
|
|
355
|
+
result.type = "array";
|
|
356
|
+
if (schema.elementSchema !== void 0) result.items = flagToJsonSchemaType(schema.elementSchema);
|
|
357
|
+
break;
|
|
358
|
+
case "custom": break;
|
|
359
|
+
case "count":
|
|
360
|
+
result.type = "integer";
|
|
361
|
+
result.minimum = 0;
|
|
362
|
+
break;
|
|
363
|
+
case "keyValue":
|
|
364
|
+
result.type = "object";
|
|
365
|
+
result.additionalProperties = { type: "string" };
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
if (schema.description !== void 0) result.description = schema.description;
|
|
369
|
+
if (schema.presence === "defaulted" && isJsonSerializable(schema.defaultValue)) result.default = schema.defaultValue;
|
|
370
|
+
if (schema.deprecated !== void 0) result.deprecated = schema.deprecated;
|
|
371
|
+
return result;
|
|
372
|
+
}
|
|
373
|
+
function argToJsonSchemaType(schema) {
|
|
374
|
+
const kind = argKindToType(schema);
|
|
375
|
+
const result = schema.variadic ? {
|
|
376
|
+
type: "array",
|
|
377
|
+
items: kind
|
|
378
|
+
} : { ...kind };
|
|
379
|
+
if (schema.description !== void 0) result.description = schema.description;
|
|
380
|
+
if (schema.presence === "defaulted" && isJsonSerializable(schema.defaultValue)) result.default = schema.defaultValue;
|
|
381
|
+
if (schema.deprecated !== void 0) result.deprecated = schema.deprecated;
|
|
382
|
+
return result;
|
|
383
|
+
}
|
|
384
|
+
/** Map an arg's kind to a JSON Schema type fragment. */
|
|
385
|
+
function argKindToType(schema) {
|
|
386
|
+
switch (schema.kind) {
|
|
387
|
+
case "string": return { type: "string" };
|
|
388
|
+
case "number": {
|
|
389
|
+
const constraints = schema.numberConstraints;
|
|
390
|
+
const result = { type: constraints?.int === true ? "integer" : "number" };
|
|
391
|
+
if (constraints?.min !== void 0) result.minimum = constraints.min;
|
|
392
|
+
if (constraints?.max !== void 0) result.maximum = constraints.max;
|
|
393
|
+
return result;
|
|
394
|
+
}
|
|
395
|
+
case "enum": {
|
|
396
|
+
const result = { type: "string" };
|
|
397
|
+
if (schema.enumValues !== void 0) result.enum = [...schema.enumValues];
|
|
398
|
+
return result;
|
|
399
|
+
}
|
|
400
|
+
case "custom": return {};
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Check whether a value can survive a JSON round-trip.
|
|
405
|
+
*
|
|
406
|
+
* Returns `false` for functions, symbols, bigints, non-finite numbers, and
|
|
407
|
+
* objects containing them. Used to guard default-value inclusion in
|
|
408
|
+
* serialized output.
|
|
409
|
+
*/
|
|
410
|
+
function isJsonSerializable(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
411
|
+
if (value === void 0) return false;
|
|
412
|
+
if (value === null) return true;
|
|
413
|
+
const t = typeof value;
|
|
414
|
+
if (t === "string" || t === "boolean") return true;
|
|
415
|
+
if (t === "number") return Number.isFinite(value);
|
|
416
|
+
if (t === "function" || t === "symbol" || t === "bigint") return false;
|
|
417
|
+
if (Array.isArray(value)) {
|
|
418
|
+
if (seen.has(value)) return false;
|
|
419
|
+
seen.add(value);
|
|
420
|
+
try {
|
|
421
|
+
return value.every((entry) => isJsonSerializable(entry, seen));
|
|
422
|
+
} finally {
|
|
423
|
+
seen.delete(value);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
if (t === "object") {
|
|
427
|
+
const objectValue = value;
|
|
428
|
+
if (!isPlainJsonObject(objectValue)) return false;
|
|
429
|
+
if (seen.has(objectValue)) return false;
|
|
430
|
+
seen.add(objectValue);
|
|
431
|
+
try {
|
|
432
|
+
return Object.values(objectValue).every((entry) => isJsonSerializable(entry, seen));
|
|
433
|
+
} finally {
|
|
434
|
+
seen.delete(objectValue);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Check whether an object is a plain JSON object.
|
|
441
|
+
*
|
|
442
|
+
* Accepts objects with `Object.prototype` or a null prototype, which are the
|
|
443
|
+
* only object shapes that round-trip through JSON as structural objects.
|
|
444
|
+
*
|
|
445
|
+
* @internal
|
|
446
|
+
*/
|
|
447
|
+
function isPlainJsonObject(value) {
|
|
448
|
+
const proto = Object.getPrototypeOf(value);
|
|
449
|
+
return proto === Object.prototype || proto === null;
|
|
450
|
+
}
|
|
451
|
+
/** Convert a DSL string to a JSON Schema object definition. */
|
|
452
|
+
function def(source) {
|
|
453
|
+
return nodeToJsonSchema(parseSchema(source));
|
|
454
|
+
}
|
|
455
|
+
function withDefinitionDescriptions(schema, descriptions) {
|
|
456
|
+
const propertiesValue = schema.properties;
|
|
457
|
+
const describedProperties = typeof propertiesValue === "object" && propertiesValue !== null && isPlainJsonObject(propertiesValue) && descriptions.properties !== void 0 ? Object.fromEntries(Object.entries(propertiesValue).map(([name, propertySchema]) => {
|
|
458
|
+
const propertyDescriptions = descriptions.properties?.[name];
|
|
459
|
+
if (propertyDescriptions === void 0 || typeof propertySchema !== "object" || propertySchema === null || !isPlainJsonObject(propertySchema)) return [name, propertySchema];
|
|
460
|
+
return [name, withDefinitionDescriptions(propertySchema, propertyDescriptions)];
|
|
461
|
+
})) : void 0;
|
|
462
|
+
return {
|
|
463
|
+
...schema,
|
|
464
|
+
...descriptions.description !== void 0 ? { description: descriptions.description } : {},
|
|
465
|
+
...describedProperties !== void 0 ? { properties: describedProperties } : {}
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
function withDefinitionMetaSchemaDescriptions(schema, descriptions) {
|
|
469
|
+
const describedRoot = withDefinitionDescriptions(schema, descriptions.root);
|
|
470
|
+
const defsValue = describedRoot.$defs;
|
|
471
|
+
if (typeof defsValue !== "object" || defsValue === null || !isPlainJsonObject(defsValue)) return describedRoot;
|
|
472
|
+
return {
|
|
473
|
+
...describedRoot,
|
|
474
|
+
$defs: Object.fromEntries(Object.entries(defsValue).map(([name, defSchema]) => {
|
|
475
|
+
const defDescriptions = descriptions.defs[name];
|
|
476
|
+
if (defDescriptions === void 0 || typeof defSchema !== "object" || defSchema === null || !isPlainJsonObject(defSchema)) return [name, defSchema];
|
|
477
|
+
return [name, withDefinitionDescriptions(defSchema, defDescriptions)];
|
|
478
|
+
}))
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* JSON Schema (draft 2020-12) that validates the output of {@link generateSchema}.
|
|
483
|
+
*
|
|
484
|
+
* Each `$defs` entry is defined once as a schema DSL string — the DSL
|
|
485
|
+
* parser produces a runtime AST, and {@link nodeToJsonSchema} converts
|
|
486
|
+
* that AST to a JSON Schema fragment. No probe fixtures, no override
|
|
487
|
+
* maps, no manually maintained type definitions.
|
|
488
|
+
*
|
|
489
|
+
* Hosted at {@link DEFINITION_SCHEMA_URL} for `$schema` resolution. Also
|
|
490
|
+
* exported so tooling can validate definition documents without a network
|
|
491
|
+
* round-trip.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```ts
|
|
495
|
+
* import Ajv from 'ajv/dist/2020';
|
|
496
|
+
* import { definitionMetaSchema, generateSchema } from '@kjanat/dreamcli';
|
|
497
|
+
*
|
|
498
|
+
* const ajv = new Ajv();
|
|
499
|
+
* const validate = ajv.compile(definitionMetaSchema);
|
|
500
|
+
* const valid = validate(generateSchema(myCli.schema));
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
503
|
+
const definitionMetaSchema = withDefinitionMetaSchemaDescriptions({
|
|
504
|
+
$schema: JSON_SCHEMA_DRAFT,
|
|
505
|
+
$id: DEFINITION_SCHEMA_URL,
|
|
506
|
+
title: "@kjanat/dreamcli definition schema",
|
|
507
|
+
description: "Describes the structure of a CLI built with dreamcli — commands, flags, args, types, constraints, env bindings, and prompts.",
|
|
508
|
+
...def(`{
|
|
509
|
+
$schema: '${DEFINITION_SCHEMA_URL}';
|
|
3
510
|
name: string;
|
|
4
511
|
version?: string;
|
|
5
512
|
description?: string;
|
|
6
|
-
defaultCommand?:
|
|
513
|
+
defaultCommand?: @command;
|
|
7
514
|
commands: @command[]
|
|
8
|
-
}`)
|
|
515
|
+
}`),
|
|
516
|
+
$defs: {
|
|
517
|
+
command: def(`{
|
|
9
518
|
name: string;
|
|
10
519
|
description?: string;
|
|
11
520
|
aliases?: string[];
|
|
@@ -14,8 +523,9 @@ import{getFlagAliasNames as e}from"../schema/flag.mjs";import{parseSchema as t}f
|
|
|
14
523
|
flags: Record<string, @flag>;
|
|
15
524
|
args: @arg[];
|
|
16
525
|
commands: @command[]
|
|
17
|
-
}`),
|
|
18
|
-
|
|
526
|
+
}`),
|
|
527
|
+
flag: def(`{
|
|
528
|
+
kind: 'string' | 'number' | 'boolean' | 'enum' | 'array' | 'custom' | 'count' | 'keyValue';
|
|
19
529
|
presence: 'optional' | 'required' | 'defaulted';
|
|
20
530
|
defaultValue?: unknown;
|
|
21
531
|
aliases?: string[];
|
|
@@ -26,8 +536,15 @@ import{getFlagAliasNames as e}from"../schema/flag.mjs";import{parseSchema as t}f
|
|
|
26
536
|
elementSchema?: @flag;
|
|
27
537
|
prompt?: @prompt;
|
|
28
538
|
deprecated?: string | true;
|
|
29
|
-
propagate?: true
|
|
30
|
-
|
|
539
|
+
propagate?: true;
|
|
540
|
+
negation?: @negation;
|
|
541
|
+
duplicates?: 'last' | 'first' | 'error'
|
|
542
|
+
}`),
|
|
543
|
+
negation: def(`{
|
|
544
|
+
alias?: string;
|
|
545
|
+
hidden?: true
|
|
546
|
+
}`),
|
|
547
|
+
arg: def(`{
|
|
31
548
|
name: string;
|
|
32
549
|
kind: 'string' | 'number' | 'enum' | 'custom';
|
|
33
550
|
presence: 'required' | 'optional' | 'defaulted';
|
|
@@ -38,18 +555,25 @@ import{getFlagAliasNames as e}from"../schema/flag.mjs";import{parseSchema as t}f
|
|
|
38
555
|
envVar?: string;
|
|
39
556
|
enumValues?: string[];
|
|
40
557
|
deprecated?: string | true
|
|
41
|
-
}`),
|
|
558
|
+
}`),
|
|
559
|
+
prompt: def(`{
|
|
42
560
|
kind: 'confirm' | 'input' | 'select' | 'multiselect';
|
|
43
561
|
message: string;
|
|
44
562
|
placeholder?: string;
|
|
45
563
|
choices?: @choice[];
|
|
46
564
|
min?: integer;
|
|
47
565
|
max?: integer
|
|
48
|
-
}`),
|
|
566
|
+
}`),
|
|
567
|
+
choice: def(`{
|
|
49
568
|
value: string;
|
|
50
569
|
label?: string;
|
|
51
570
|
description?: string
|
|
52
|
-
}`),
|
|
571
|
+
}`),
|
|
572
|
+
example: def(`{
|
|
53
573
|
command: string;
|
|
54
574
|
description?: string
|
|
55
|
-
}`)
|
|
575
|
+
}`)
|
|
576
|
+
}
|
|
577
|
+
}, definitionMetaSchemaDescriptions);
|
|
578
|
+
//#endregion
|
|
579
|
+
export { definitionMetaSchema, generateCommandSchema, generateInputSchema, generateSchema };
|
|
@@ -92,7 +92,24 @@ declare const definitionMetaSchemaDescriptions: {
|
|
|
92
92
|
readonly description: "Deprecation marker.\n\n- `undefined` — not deprecated (default)\n- `true` — deprecated with no migration message\n- `string` — deprecated with a reason/migration message\n\nWhen a deprecated flag is used, a warning is emitted to stderr.\nHelp text shows `[deprecated]` or `[deprecated: <reason>]`.";
|
|
93
93
|
};
|
|
94
94
|
readonly propagate: {
|
|
95
|
-
readonly description: "Whether this flag propagates to subcommands in nested command trees.\n\nWhen `true`, the flag is automatically available to all descendant\ncommands. A child command that defines a flag with the same name\nshadows the propagated parent flag
|
|
95
|
+
readonly description: "Whether this flag propagates to subcommands in nested command trees.\n\nWhen `true`, the flag is automatically available to all descendant\ncommands. A child command that defines a flag with the same name\nshadows the propagated parent flag.\n\nDefault: `false`";
|
|
96
|
+
};
|
|
97
|
+
readonly negation: {
|
|
98
|
+
readonly description: "Negation settings when `kind === 'boolean'` and `.negatable()` was\ncalled (`undefined` otherwise). See FlagNegation.";
|
|
99
|
+
};
|
|
100
|
+
readonly duplicates: {
|
|
101
|
+
readonly description: "How repeated CLI occurrences of a singleton flag combine.\n\n- `'last'` — last occurrence wins (matches historic behavior)\n- `'first'` — first occurrence wins; later ones parse but are ignored\n- `'error'` — a second occurrence is a `ParseError` (`DUPLICATE_FLAG`)\n\nApplies to CLI token occurrences only — env/config/prompt/default\nresolution keeps its precedence semantics and never raises duplicates.\nOccurrences are counted per *logical* flag: aliases and the negated\nspelling all count toward the same flag.\n\nDefault: `'last'`";
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
readonly negation: {
|
|
106
|
+
readonly description: "Negation settings for a boolean flag (set by `.negatable()`).\n\nThe negated spelling and the positive form are two spellings of ONE\nlogical flag: they share duplicate policy, and the last CLI occurrence\nwins across both. The negated spelling is presence-only — `--no-foo=x`\nis rejected.";
|
|
107
|
+
readonly properties: {
|
|
108
|
+
readonly alias: {
|
|
109
|
+
readonly description: "Explicit negated spelling without the `--` prefix (e.g. `'no-sandbox'`).\n`undefined` synthesizes `no-<flagName>` wherever the flag name is known.";
|
|
110
|
+
};
|
|
111
|
+
readonly hidden: {
|
|
112
|
+
readonly description: "Hide the negated spelling from help, completions, and suggestions.";
|
|
96
113
|
};
|
|
97
114
|
};
|
|
98
115
|
};
|
|
@@ -112,7 +129,7 @@ declare const definitionMetaSchemaDescriptions: {
|
|
|
112
129
|
readonly description: "Whether this arg consumes all remaining positionals.";
|
|
113
130
|
};
|
|
114
131
|
readonly stdinMode: {
|
|
115
|
-
readonly description: "Whether this arg may read from stdin during resolution
|
|
132
|
+
readonly description: "Whether this arg may read from stdin during resolution.\n\nDefault: `false`";
|
|
116
133
|
};
|
|
117
134
|
readonly defaultValue: {
|
|
118
135
|
readonly description: "Runtime default value (if any).";
|
|
@@ -147,10 +164,10 @@ declare const definitionMetaSchemaDescriptions: {
|
|
|
147
164
|
readonly description: "Available choices. When omitted for `enum` flags, the enum values\nfrom the flag schema are used automatically.";
|
|
148
165
|
};
|
|
149
166
|
readonly min: {
|
|
150
|
-
readonly description: "Minimum number of selections required
|
|
167
|
+
readonly description: "Minimum number of selections required.\n\nDefault: `0`";
|
|
151
168
|
};
|
|
152
169
|
readonly max: {
|
|
153
|
-
readonly description: "Maximum number of selections allowed
|
|
170
|
+
readonly description: "Maximum number of selections allowed.\n\nDefault: `Infinity`";
|
|
154
171
|
};
|
|
155
172
|
};
|
|
156
173
|
};
|
|
@@ -161,7 +178,7 @@ declare const definitionMetaSchemaDescriptions: {
|
|
|
161
178
|
readonly description: "The value returned when this choice is selected.";
|
|
162
179
|
};
|
|
163
180
|
readonly label: {
|
|
164
|
-
readonly description: "Display label shown to the user
|
|
181
|
+
readonly description: "Display label shown to the user.\n\nDefault: value";
|
|
165
182
|
};
|
|
166
183
|
readonly description: {
|
|
167
184
|
readonly description: "Optional description shown alongside the choice.";
|