@politty/zod 0.1.2 → 0.2.1
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/README.md +31 -0
- package/dist/{arg-registry-Be4GJADw.d.ts → arg-registry-BzQ-y-e0.d.ts} +2 -2
- package/dist/augment.d.ts +1 -1
- package/dist/augment.js +1 -1
- package/dist/cli-main-B4FX3h4J.js +1 -0
- package/dist/cli-main-CjYk6tAX.js +2 -0
- package/dist/cli-run-DN55A0JZ.js +1 -0
- package/dist/cli.js +1 -15
- package/dist/command-Mbdt0bmN.js +1 -0
- package/dist/compile-cache-VuUbFWIo.js +1 -0
- package/dist/compile-cache.js +1 -3
- package/dist/completion-D8DMrPqg.js +116 -0
- package/dist/completion-DUMcvXkT.js +1 -0
- package/dist/completion.d.ts +87 -7
- package/dist/completion.js +1 -4
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +84 -3063
- package/dist/dynamic-CMtee4tD.js +1 -0
- package/dist/dynamic-CrnlveHj.js +6 -0
- package/dist/field-meta-COGya7xp.js +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -27
- package/dist/log-collector-DICKib75.js +1 -0
- package/dist/logger-CJsyJ8sb.js +1 -0
- package/dist/prompt-CqmGq1_N.js +1 -0
- package/dist/prompt-clack.d.ts +1 -1
- package/dist/prompt-clack.js +1 -32
- package/dist/prompt-inquirer.d.ts +1 -1
- package/dist/prompt-inquirer.js +1 -47
- package/dist/prompt.d.ts +1 -1
- package/dist/prompt.js +1 -4
- package/dist/register-C1WbbeYH.js +1 -0
- package/dist/runner-BIdcntiz.js +29 -0
- package/dist/runner-Chaf_5lK.js +1 -0
- package/dist/schema-BiUP_KyV.js +1 -0
- package/dist/schema-extractor-DU0Vuhbd.js +1 -0
- package/dist/skill.d.ts +1 -1
- package/dist/skill.js +2 -1837
- package/dist/subcommand-router-D8GTMXYL.js +1 -0
- package/dist/{index-B4NylQOW.d.ts → with-completion-command-CmVdHFHX.d.ts} +3 -74
- package/dist/with-completion-command-DDohm8U6.js +3 -0
- package/package.json +3 -3
- package/dist/cli-main-CAa5KwCo.js +0 -314
- package/dist/cli-main-DIRMduj1.js +0 -3
- package/dist/cli-run-B--tZW_I.js +0 -8
- package/dist/command-k-4yAz4J.js +0 -42
- package/dist/compile-cache-BC65o7MH.js +0 -103
- package/dist/completion-Ot2qpNNw.js +0 -5616
- package/dist/field-meta-CO38jOvl.js +0 -148
- package/dist/log-collector-CoUkLVJB.js +0 -114
- package/dist/logger-i_bb-Jhc.js +0 -133
- package/dist/prompt-BjIZThsH.js +0 -169
- package/dist/register-DdcsbNwM.js +0 -440
- package/dist/runner-Bz3arOqh.js +0 -3051
- package/dist/runner-Cs-Mz9JN.js +0 -3
- package/dist/schema-extractor-CVNDs07l.js +0 -250
- package/dist/src-D4QGGgW1.js +0 -6
- package/dist/src-DhQVU2hG.js +0 -12
- package/dist/subcommand-router-Cskpofdk.js +0 -134
package/dist/runner-Cs-Mz9JN.js
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { a as getValidatorAdapter, n as resolveFieldMeta } from "./field-meta-CO38jOvl.js";
|
|
2
|
-
|
|
3
|
-
//#region ../core/src/adapter/internal-args.ts
|
|
4
|
-
/** Runtime brand distinguishing internal descriptors from library schemas. */
|
|
5
|
-
const INTERNAL_ARGS_BRAND = "__polittyInternalArgs";
|
|
6
|
-
/**
|
|
7
|
-
* Field builders for {@link internalArgs}. Only the shapes internal
|
|
8
|
-
* commands actually need; extend deliberately, not speculatively.
|
|
9
|
-
*/
|
|
10
|
-
const internalField = {
|
|
11
|
-
/** Required string */
|
|
12
|
-
string(meta) {
|
|
13
|
-
return {
|
|
14
|
-
kind: "string",
|
|
15
|
-
optional: false,
|
|
16
|
-
meta
|
|
17
|
-
};
|
|
18
|
-
},
|
|
19
|
-
/** Optional string (undefined when omitted) */
|
|
20
|
-
optionalString(meta) {
|
|
21
|
-
return {
|
|
22
|
-
kind: "string",
|
|
23
|
-
optional: true,
|
|
24
|
-
meta
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
/** Boolean flag defaulting to false */
|
|
28
|
-
boolean(meta) {
|
|
29
|
-
return {
|
|
30
|
-
kind: "boolean",
|
|
31
|
-
optional: false,
|
|
32
|
-
defaultValue: false,
|
|
33
|
-
meta
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
/** Required enum */
|
|
37
|
-
enum(values, meta) {
|
|
38
|
-
return {
|
|
39
|
-
kind: "enum",
|
|
40
|
-
enumValues: values,
|
|
41
|
-
optional: false,
|
|
42
|
-
meta
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
/** Optional enum (undefined when omitted) */
|
|
46
|
-
optionalEnum(values, meta) {
|
|
47
|
-
return {
|
|
48
|
-
kind: "enum",
|
|
49
|
-
enumValues: values,
|
|
50
|
-
optional: true,
|
|
51
|
-
meta
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
/** String array defaulting to [] */
|
|
55
|
-
stringArray(meta) {
|
|
56
|
-
return {
|
|
57
|
-
kind: "string-array",
|
|
58
|
-
optional: false,
|
|
59
|
-
defaultValue: [],
|
|
60
|
-
meta
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
/** Optional string array (undefined when omitted) */
|
|
64
|
-
optionalStringArray(meta) {
|
|
65
|
-
return {
|
|
66
|
-
kind: "string-array",
|
|
67
|
-
optional: true,
|
|
68
|
-
meta
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Build an internal args schema from field descriptors.
|
|
74
|
-
*/
|
|
75
|
-
function internalArgs(fields, options = {}) {
|
|
76
|
-
return {
|
|
77
|
-
[INTERNAL_ARGS_BRAND]: true,
|
|
78
|
-
fields,
|
|
79
|
-
unknownKeys: options.unknownKeys ?? "strip"
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Runtime check for the internal descriptor brand. The extract/validate
|
|
84
|
-
* facades call this before falling back to the schema-library adapter.
|
|
85
|
-
*/
|
|
86
|
-
function isInternalArgsSchema(schema) {
|
|
87
|
-
return typeof schema === "object" && schema !== null && schema[INTERNAL_ARGS_BRAND] === true;
|
|
88
|
-
}
|
|
89
|
-
const FIELD_TYPE = {
|
|
90
|
-
string: "string",
|
|
91
|
-
boolean: "boolean",
|
|
92
|
-
enum: "string",
|
|
93
|
-
"string-array": "array"
|
|
94
|
-
};
|
|
95
|
-
const extractCache = /* @__PURE__ */ new WeakMap();
|
|
96
|
-
/**
|
|
97
|
-
* Extract neutral field metadata from an internal args schema.
|
|
98
|
-
*/
|
|
99
|
-
function extractInternalFields(schema) {
|
|
100
|
-
const cached = extractCache.get(schema);
|
|
101
|
-
if (cached) return cached;
|
|
102
|
-
const result = {
|
|
103
|
-
fields: Object.entries(schema.fields).map(([name, spec]) => resolveFieldMeta(name, {
|
|
104
|
-
argMeta: spec.meta,
|
|
105
|
-
description: void 0,
|
|
106
|
-
required: !spec.optional && spec.defaultValue === void 0,
|
|
107
|
-
defaultValue: spec.defaultValue,
|
|
108
|
-
type: FIELD_TYPE[spec.kind],
|
|
109
|
-
enumValues: spec.enumValues ? [...spec.enumValues] : void 0,
|
|
110
|
-
schema: spec
|
|
111
|
-
})),
|
|
112
|
-
schema,
|
|
113
|
-
schemaType: "object",
|
|
114
|
-
unknownKeysMode: schema.unknownKeys
|
|
115
|
-
};
|
|
116
|
-
extractCache.set(schema, result);
|
|
117
|
-
return result;
|
|
118
|
-
}
|
|
119
|
-
function expectedLabel(spec) {
|
|
120
|
-
switch (spec.kind) {
|
|
121
|
-
case "enum": return `one of ${(spec.enumValues ?? []).map((v) => JSON.stringify(v)).join(" | ")}`;
|
|
122
|
-
case "string-array": return "array";
|
|
123
|
-
default: return spec.kind;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function receivedLabel(value) {
|
|
127
|
-
if (value === null) return "null";
|
|
128
|
-
if (Array.isArray(value)) return "array";
|
|
129
|
-
return typeof value;
|
|
130
|
-
}
|
|
131
|
-
function typeError(name, spec, received) {
|
|
132
|
-
return {
|
|
133
|
-
path: [name],
|
|
134
|
-
message: `Invalid input: expected ${expectedLabel(spec)}, received ${receivedLabel(received)}`,
|
|
135
|
-
code: "invalid_type",
|
|
136
|
-
received,
|
|
137
|
-
expected: expectedLabel(spec)
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function checkValue(name, spec, value) {
|
|
141
|
-
switch (spec.kind) {
|
|
142
|
-
case "string": return typeof value === "string" ? null : typeError(name, spec, value);
|
|
143
|
-
case "boolean": return typeof value === "boolean" ? null : typeError(name, spec, value);
|
|
144
|
-
case "enum":
|
|
145
|
-
if (typeof value !== "string" || !(spec.enumValues ?? []).includes(value)) return {
|
|
146
|
-
path: [name],
|
|
147
|
-
message: `Invalid option: expected ${expectedLabel(spec)}`,
|
|
148
|
-
code: "invalid_value",
|
|
149
|
-
received: value,
|
|
150
|
-
expected: expectedLabel(spec)
|
|
151
|
-
};
|
|
152
|
-
return null;
|
|
153
|
-
case "string-array":
|
|
154
|
-
if (!Array.isArray(value) || value.some((v) => typeof v !== "string")) return typeError(name, spec, value);
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Validate raw parsed args against an internal args schema. Mirrors the
|
|
160
|
-
* schema-library semantics the parser relies on: defaults fill missing
|
|
161
|
-
* values, optional fields stay absent, and unknown keys follow the
|
|
162
|
-
* descriptor's `unknownKeys` mode (strip by default, like z.object()).
|
|
163
|
-
*/
|
|
164
|
-
function validateInternalArgs(rawArgs, schema) {
|
|
165
|
-
const errors = [];
|
|
166
|
-
const data = {};
|
|
167
|
-
for (const [name, spec] of Object.entries(schema.fields)) {
|
|
168
|
-
const value = rawArgs[name];
|
|
169
|
-
if (value === void 0) {
|
|
170
|
-
if (spec.defaultValue !== void 0) data[name] = Array.isArray(spec.defaultValue) ? [...spec.defaultValue] : spec.defaultValue;
|
|
171
|
-
else if (!spec.optional) errors.push(typeError(name, spec, void 0));
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
const error = checkValue(name, spec, value);
|
|
175
|
-
if (error) {
|
|
176
|
-
errors.push(error);
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
data[name] = value;
|
|
180
|
-
}
|
|
181
|
-
const knownNames = new Set(Object.keys(schema.fields));
|
|
182
|
-
const unknownKeys = Object.keys(rawArgs).filter((key) => !knownNames.has(key));
|
|
183
|
-
if (unknownKeys.length > 0) {
|
|
184
|
-
if (schema.unknownKeys === "strict") errors.push({
|
|
185
|
-
path: [],
|
|
186
|
-
message: `Unrecognized key${unknownKeys.length > 1 ? "s" : ""}: ${unknownKeys.map((k) => JSON.stringify(k)).join(", ")}`,
|
|
187
|
-
code: "unrecognized_keys"
|
|
188
|
-
});
|
|
189
|
-
else if (schema.unknownKeys === "passthrough") for (const key of unknownKeys) Object.defineProperty(data, key, {
|
|
190
|
-
value: rawArgs[key],
|
|
191
|
-
enumerable: true,
|
|
192
|
-
writable: true,
|
|
193
|
-
configurable: true
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
if (errors.length > 0) return {
|
|
197
|
-
success: false,
|
|
198
|
-
errors
|
|
199
|
-
};
|
|
200
|
-
return {
|
|
201
|
-
success: true,
|
|
202
|
-
data
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
//#endregion
|
|
207
|
-
//#region ../core/src/core/schema-extractor.ts
|
|
208
|
-
/**
|
|
209
|
-
* Schema extraction facade.
|
|
210
|
-
*
|
|
211
|
-
* The neutral field-metadata shapes and naming helpers live in
|
|
212
|
-
* `adapter/field-meta.ts`; the schema-library-specific introspection lives
|
|
213
|
-
* in the registered validator adapter (e.g. `@politty/zod`). This module
|
|
214
|
-
* keeps the historical import surface (`extractFields`, `toCamelCase`, ...)
|
|
215
|
-
* stable for the rest of the codebase and for the package's public
|
|
216
|
-
* exports, and routes each schema to the implementation that understands
|
|
217
|
-
* it.
|
|
218
|
-
*/
|
|
219
|
-
/**
|
|
220
|
-
* Detect the unknown-keys handling mode of an args schema. Works for any
|
|
221
|
-
* schema politty itself attaches to a command (including internal
|
|
222
|
-
* descriptor-based commands), not just user-provided library schemas.
|
|
223
|
-
*/
|
|
224
|
-
function getUnknownKeysMode(schema) {
|
|
225
|
-
if (isInternalArgsSchema(schema)) return schema.unknownKeys;
|
|
226
|
-
return getValidatorAdapter().getUnknownKeysMode(schema);
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Extract all fields from a schema
|
|
230
|
-
*
|
|
231
|
-
* @param schema - The args schema (ZodObject, ZodDiscriminatedUnion, etc.)
|
|
232
|
-
* @returns Extracted field information
|
|
233
|
-
*/
|
|
234
|
-
function extractFields(schema) {
|
|
235
|
-
if (isInternalArgsSchema(schema)) return extractInternalFields(schema);
|
|
236
|
-
return getValidatorAdapter().extractFields(schema);
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Get extracted fields from a command
|
|
240
|
-
*
|
|
241
|
-
* @param command - The command to extract fields from
|
|
242
|
-
* @returns Extracted field information, or null if command has no args schema
|
|
243
|
-
*/
|
|
244
|
-
function getExtractedFields(command) {
|
|
245
|
-
if (!command.args) return null;
|
|
246
|
-
return extractFields(command.args);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
//#endregion
|
|
250
|
-
export { internalField as a, internalArgs as i, getExtractedFields as n, isInternalArgsSchema as o, getUnknownKeysMode as r, validateInternalArgs as s, extractFields as t };
|
package/dist/src-D4QGGgW1.js
DELETED
package/dist/src-DhQVU2hG.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { i as toKebabCase, r as toCamelCase } from "./field-meta-CO38jOvl.js";
|
|
2
|
-
import { t as arg } from "./register-DdcsbNwM.js";
|
|
3
|
-
import { r as getUnknownKeysMode, t as extractFields } from "./schema-extractor-CVNDs07l.js";
|
|
4
|
-
import { n as createCompileCacheShimGenerator, t as runPolittyCli } from "./cli-main-CAa5KwCo.js";
|
|
5
|
-
import { n as defineCommand, t as createDefineCommand } from "./command-k-4yAz4J.js";
|
|
6
|
-
import { C as ReservedFieldNameError, E as renderMarkdown, S as ReservedAliasError, T as renderInline, _ as DuplicateAliasError, a as parseArgv, b as FieldTypeConflictError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as CaseVariantCollisionError, h as validateReservedFieldNames, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, r as createDualCaseProxy, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateFieldError, w as generateHelp, x as PositionalConfigError, y as DuplicateNegationError } from "./runner-Bz3arOqh.js";
|
|
7
|
-
import { o as isLazyCommand, s as lazy } from "./subcommand-router-Cskpofdk.js";
|
|
8
|
-
import { a as symbols, i as styles, n as logger, r as setColorEnabled, t as isColorEnabled } from "./logger-i_bb-Jhc.js";
|
|
9
|
-
import { a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand } from "./completion-Ot2qpNNw.js";
|
|
10
|
-
import "./src-D4QGGgW1.js";
|
|
11
|
-
|
|
12
|
-
export { generateBundledCompletionWorker };
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
//#region ../core/src/lazy.ts
|
|
2
|
-
/**
|
|
3
|
-
* Marker property for LazyCommand identification
|
|
4
|
-
*/
|
|
5
|
-
const LAZY_BRAND = "__politty_lazy__";
|
|
6
|
-
/**
|
|
7
|
-
* Type guard: check if a value is a LazyCommand
|
|
8
|
-
*/
|
|
9
|
-
function isLazyCommand(value) {
|
|
10
|
-
return typeof value === "object" && value !== null && LAZY_BRAND in value && value[LAZY_BRAND] === true;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Create a lazily-loaded subcommand with synchronous metadata.
|
|
14
|
-
*
|
|
15
|
-
* The `meta` command provides names, descriptions, and args schema
|
|
16
|
-
* for static analysis (completion scripts, help text) without loading
|
|
17
|
-
* the full command module.
|
|
18
|
-
*
|
|
19
|
-
* The `load` function is called only at execution time.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* import { lazy, defineCommand } from "politty";
|
|
24
|
-
*
|
|
25
|
-
* const cli = defineCommand({
|
|
26
|
-
* name: "mycli",
|
|
27
|
-
* subCommands: {
|
|
28
|
-
* deploy: lazy(
|
|
29
|
-
* defineCommand({
|
|
30
|
-
* name: "deploy",
|
|
31
|
-
* description: "Deploy the application",
|
|
32
|
-
* args: z.object({ env: arg(z.string()) }),
|
|
33
|
-
* }),
|
|
34
|
-
* () => import("./deploy.js").then((m) => m.deployCommand),
|
|
35
|
-
* ),
|
|
36
|
-
* },
|
|
37
|
-
* });
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
function lazy(meta, load) {
|
|
41
|
-
return {
|
|
42
|
-
[LAZY_BRAND]: true,
|
|
43
|
-
meta,
|
|
44
|
-
load
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Resolve synchronous metadata from a SubCommandValue.
|
|
49
|
-
* Returns null for legacy async subcommands whose metadata is unavailable.
|
|
50
|
-
*/
|
|
51
|
-
function resolveSubCommandMeta(subCmd) {
|
|
52
|
-
if (isLazyCommand(subCmd)) return subCmd.meta;
|
|
53
|
-
if (typeof subCmd === "function") return null;
|
|
54
|
-
return subCmd;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region ../core/src/executor/subcommand-router.ts
|
|
59
|
-
/**
|
|
60
|
-
* Resolve a lazy-loaded command (sync or async)
|
|
61
|
-
*
|
|
62
|
-
* @param cmd - The command or lazy loader function
|
|
63
|
-
* @returns The resolved command
|
|
64
|
-
*/
|
|
65
|
-
async function resolveLazyCommand(cmd) {
|
|
66
|
-
if (isLazyCommand(cmd)) return await cmd.load();
|
|
67
|
-
if (typeof cmd === "function") return await cmd();
|
|
68
|
-
return cmd;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Resolve a subcommand by name (including alias lookup) and return both the
|
|
72
|
-
* resolved command and the canonical name if accessed via alias.
|
|
73
|
-
*
|
|
74
|
-
* This avoids a redundant alias scan when the caller needs both pieces of info.
|
|
75
|
-
*/
|
|
76
|
-
async function resolveSubcommandWithAlias(command, name) {
|
|
77
|
-
if (!command.subCommands) return;
|
|
78
|
-
const subCmd = Object.hasOwn(command.subCommands, name) ? command.subCommands[name] : void 0;
|
|
79
|
-
if (subCmd) return {
|
|
80
|
-
command: await resolveLazyCommand(subCmd),
|
|
81
|
-
aliasFor: void 0
|
|
82
|
-
};
|
|
83
|
-
const canonicalName = resolveSubCommandAlias(command, name);
|
|
84
|
-
if (canonicalName) return {
|
|
85
|
-
command: await resolveLazyCommand(command.subCommands[canonicalName]),
|
|
86
|
-
aliasFor: canonicalName
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Resolve an alias to the canonical subcommand name.
|
|
91
|
-
* Returns the canonical name if the given name is an alias, or undefined.
|
|
92
|
-
*
|
|
93
|
-
* Note: Aliases are only recognized for eagerly-defined commands and
|
|
94
|
-
* `lazy()` commands (which carry synchronous metadata). Pure async
|
|
95
|
-
* subcommand functions do not expose metadata synchronously, so their
|
|
96
|
-
* aliases cannot be resolved without loading the module.
|
|
97
|
-
*
|
|
98
|
-
* @param command - The parent command
|
|
99
|
-
* @param alias - The alias to look up
|
|
100
|
-
* @returns The canonical subcommand name, or undefined
|
|
101
|
-
*/
|
|
102
|
-
function resolveSubCommandAlias(command, alias) {
|
|
103
|
-
if (!command.subCommands) return void 0;
|
|
104
|
-
for (const [name, subCmd] of Object.entries(command.subCommands)) if (resolveSubCommandMeta(subCmd)?.aliases?.includes(alias)) return name;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Build a set of all recognized subcommand names including aliases.
|
|
108
|
-
*
|
|
109
|
-
* @param command - The parent command
|
|
110
|
-
* @returns Set of all names (canonical + aliases)
|
|
111
|
-
*/
|
|
112
|
-
function listSubCommandNamesWithAliases(command) {
|
|
113
|
-
const names = /* @__PURE__ */ new Set();
|
|
114
|
-
if (!command.subCommands) return names;
|
|
115
|
-
for (const [name, subCmd] of Object.entries(command.subCommands)) {
|
|
116
|
-
names.add(name);
|
|
117
|
-
const meta = resolveSubCommandMeta(subCmd);
|
|
118
|
-
if (meta?.aliases) for (const alias of meta.aliases) names.add(alias);
|
|
119
|
-
}
|
|
120
|
-
return names;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* List all subcommand names for a command
|
|
124
|
-
*
|
|
125
|
-
* @param command - The parent command
|
|
126
|
-
* @returns Array of subcommand names
|
|
127
|
-
*/
|
|
128
|
-
function listSubCommands(command) {
|
|
129
|
-
if (!command.subCommands) return [];
|
|
130
|
-
return Object.keys(command.subCommands);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
//#endregion
|
|
134
|
-
export { resolveSubcommandWithAlias as a, resolveSubCommandMeta as c, resolveSubCommandAlias as i, listSubCommands as n, isLazyCommand as o, resolveLazyCommand as r, lazy as s, listSubCommandNamesWithAliases as t };
|