politty 0.0.1 → 0.1.0
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 +297 -28
- package/dist/arg-registry-ClI2WGgH.d.cts +89 -0
- package/dist/arg-registry-ClI2WGgH.d.cts.map +1 -0
- package/dist/arg-registry-D4NsqcNZ.d.ts +89 -0
- package/dist/arg-registry-D4NsqcNZ.d.ts.map +1 -0
- package/dist/augment.cjs +0 -0
- package/dist/augment.d.cts +17 -0
- package/dist/augment.d.cts.map +1 -0
- package/dist/augment.d.ts +17 -0
- package/dist/augment.d.ts.map +1 -0
- package/dist/augment.js +1 -0
- package/dist/command-Bgd-yIwv.cjs +25 -0
- package/dist/command-Bgd-yIwv.cjs.map +1 -0
- package/dist/command-CvKyk4ag.js +20 -0
- package/dist/command-CvKyk4ag.js.map +1 -0
- package/dist/completion/index.cjs +595 -0
- package/dist/completion/index.cjs.map +1 -0
- package/dist/completion/index.d.cts +153 -0
- package/dist/completion/index.d.cts.map +1 -0
- package/dist/completion/index.d.ts +153 -0
- package/dist/completion/index.d.ts.map +1 -0
- package/dist/completion/index.js +588 -0
- package/dist/completion/index.js.map +1 -0
- package/dist/docs/index.cjs +1239 -0
- package/dist/docs/index.cjs.map +1 -0
- package/dist/docs/index.d.cts +500 -0
- package/dist/docs/index.d.cts.map +1 -0
- package/dist/docs/index.d.ts +500 -0
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +1182 -0
- package/dist/docs/index.js.map +1 -0
- package/dist/index.cjs +28 -0
- package/dist/index.d.cts +439 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +439 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/runner-C8rhhx6L.js +1372 -0
- package/dist/runner-C8rhhx6L.js.map +1 -0
- package/dist/runner-C_m6ve-j.js +4 -0
- package/dist/runner-CmjYWlam.cjs +1486 -0
- package/dist/runner-CmjYWlam.cjs.map +1 -0
- package/dist/runner-pmoTWUXY.cjs +4 -0
- package/dist/schema-extractor-B9D3Rf22.cjs +354 -0
- package/dist/schema-extractor-B9D3Rf22.cjs.map +1 -0
- package/dist/schema-extractor-D-Eo7I77.d.cts +303 -0
- package/dist/schema-extractor-D-Eo7I77.d.cts.map +1 -0
- package/dist/schema-extractor-Dk5Z0Iei.js +324 -0
- package/dist/schema-extractor-Dk5Z0Iei.js.map +1 -0
- package/dist/schema-extractor-kkajLb9E.d.ts +303 -0
- package/dist/schema-extractor-kkajLb9E.d.ts.map +1 -0
- package/dist/subcommand-router-BiSvDXHg.js +153 -0
- package/dist/subcommand-router-BiSvDXHg.js.map +1 -0
- package/dist/subcommand-router-Vf-0w9P4.cjs +189 -0
- package/dist/subcommand-router-Vf-0w9P4.cjs.map +1 -0
- package/package.json +108 -6
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { n as arg, t as ArgMeta } from "./arg-registry-ClI2WGgH.cjs";
|
|
2
|
+
import { C as RunResultSuccess, D as SubCommandsRecord, E as SubCommandValue, S as RunResultFailure, T as SetupContext, _ as Logger, a as getUnknownKeysMode, b as RunCommandOptions, c as ArgsSchema, d as Command, f as CommandBase, g as LogStream, h as LogLevel, i as extractFields, l as CleanupContext, m as LogEntry, n as ResolvedFieldMeta, o as toKebabCase, p as Example, r as UnknownKeysMode, s as AnyCommand, t as ExtractedFields, u as CollectedLogs, v as MainOptions, w as RunnableCommand, x as RunResult, y as NonRunnableCommand } from "./schema-extractor-D-Eo7I77.cjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//#region src/core/command.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Infer args type from schema, defaults to empty object if undefined
|
|
8
|
+
*/
|
|
9
|
+
type InferArgs<TArgsSchema> = TArgsSchema extends z.ZodType ? z.infer<TArgsSchema> : Record<string, never>;
|
|
10
|
+
/**
|
|
11
|
+
* Config for defining a command
|
|
12
|
+
* @template TArgsSchema - The Zod schema type for arguments
|
|
13
|
+
* @template TResult - The return type of run function (void if no run)
|
|
14
|
+
*/
|
|
15
|
+
interface DefineCommandConfig<TArgsSchema extends ArgsSchema | undefined, TResult> {
|
|
16
|
+
name: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
args?: TArgsSchema;
|
|
19
|
+
subCommands?: SubCommandsRecord;
|
|
20
|
+
setup?: (context: {
|
|
21
|
+
args: InferArgs<TArgsSchema>;
|
|
22
|
+
}) => void | Promise<void>;
|
|
23
|
+
run?: (args: InferArgs<TArgsSchema>) => TResult;
|
|
24
|
+
cleanup?: (context: {
|
|
25
|
+
args: InferArgs<TArgsSchema>;
|
|
26
|
+
error?: Error | undefined;
|
|
27
|
+
}) => void | Promise<void>;
|
|
28
|
+
notes?: string;
|
|
29
|
+
examples?: Example[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Config with run function (runnable command)
|
|
33
|
+
*/
|
|
34
|
+
interface RunnableConfig<TArgsSchema extends ArgsSchema | undefined, TResult> extends DefineCommandConfig<TArgsSchema, TResult> {
|
|
35
|
+
run: (args: InferArgs<TArgsSchema>) => TResult;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Config without run function (non-runnable command)
|
|
39
|
+
*/
|
|
40
|
+
interface NonRunnableConfig<TArgsSchema extends ArgsSchema | undefined> extends Omit<DefineCommandConfig<TArgsSchema, void>, "run"> {
|
|
41
|
+
run?: undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Define a CLI command with type-safe arguments
|
|
45
|
+
*
|
|
46
|
+
* @param config - Command configuration
|
|
47
|
+
* @returns A defined command with preserved type information
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { z } from "zod";
|
|
52
|
+
* import { arg, defineCommand } from "politty";
|
|
53
|
+
*
|
|
54
|
+
* const command = defineCommand({
|
|
55
|
+
* name: "greet",
|
|
56
|
+
* args: z.object({
|
|
57
|
+
* name: arg(z.string(), { description: "Name to greet", positional: true }),
|
|
58
|
+
* loud: arg(z.boolean().default(false), { alias: "l", description: "Use uppercase" }),
|
|
59
|
+
* }),
|
|
60
|
+
* run: (args) => {
|
|
61
|
+
* const greeting = `Hello, ${args.name}!`;
|
|
62
|
+
* console.log(args.loud ? greeting.toUpperCase() : greeting);
|
|
63
|
+
* },
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* // Type of command.argsSchema is preserved as z.ZodObject<...>
|
|
67
|
+
* // Type of command.run is (args: { name: string; loud: boolean }) => void
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* // With discriminated union for subcommand-like behavior
|
|
73
|
+
* const command = defineCommand({
|
|
74
|
+
* name: "resource",
|
|
75
|
+
* args: z.discriminatedUnion("action", [
|
|
76
|
+
* z.object({
|
|
77
|
+
* action: z.literal("create"),
|
|
78
|
+
* name: arg(z.string(), { description: "Resource name" }),
|
|
79
|
+
* }),
|
|
80
|
+
* z.object({
|
|
81
|
+
* action: z.literal("delete"),
|
|
82
|
+
* id: arg(z.coerce.number(), { description: "Resource ID" }),
|
|
83
|
+
* }),
|
|
84
|
+
* ]),
|
|
85
|
+
* run: (args) => {
|
|
86
|
+
* if (args.action === "create") {
|
|
87
|
+
* console.log(`Creating ${args.name}`);
|
|
88
|
+
* } else {
|
|
89
|
+
* console.log(`Deleting ${args.id}`);
|
|
90
|
+
* }
|
|
91
|
+
* },
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
declare function defineCommand<TArgsSchema extends ArgsSchema | undefined = undefined, TResult = void>(config: RunnableConfig<TArgsSchema, TResult>): RunnableCommand<TArgsSchema, InferArgs<TArgsSchema>, TResult>;
|
|
96
|
+
declare function defineCommand<TArgsSchema extends ArgsSchema | undefined = undefined>(config: NonRunnableConfig<TArgsSchema>): NonRunnableCommand<TArgsSchema, InferArgs<TArgsSchema>>;
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/core/runner.d.ts
|
|
99
|
+
/**
|
|
100
|
+
* Run a command with the given arguments (programmatic/test usage)
|
|
101
|
+
*
|
|
102
|
+
* This function parses arguments, validates them, routes to subcommands,
|
|
103
|
+
* and executes the command. It does NOT call process.exit.
|
|
104
|
+
*
|
|
105
|
+
* @param command - The command to run
|
|
106
|
+
* @param argv - Command line arguments to parse
|
|
107
|
+
* @param options - Run options
|
|
108
|
+
* @returns The result of command execution
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* import { defineCommand, runCommand } from "politty";
|
|
113
|
+
*
|
|
114
|
+
* const command = defineCommand({
|
|
115
|
+
* name: "my-cli",
|
|
116
|
+
* args: z.object({ name: z.string() }),
|
|
117
|
+
* run: ({ name }) => console.log(`Hello, ${name}!`),
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* // In tests
|
|
121
|
+
* const result = await runCommand(command, ["--name", "World"]);
|
|
122
|
+
* expect(result.exitCode).toBe(0);
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
declare function runCommand<TResult = unknown>(command: AnyCommand, argv: string[], options?: RunCommandOptions): Promise<RunResult<TResult>>;
|
|
126
|
+
/**
|
|
127
|
+
* Run a CLI command as the main entry point
|
|
128
|
+
*
|
|
129
|
+
* This function:
|
|
130
|
+
* - Uses process.argv for arguments
|
|
131
|
+
* - Handles SIGINT/SIGTERM signals
|
|
132
|
+
* - Calls process.exit with the appropriate exit code
|
|
133
|
+
*
|
|
134
|
+
* @param command - The command to run
|
|
135
|
+
* @param options - Main options (version, debug)
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* import { defineCommand, runMain } from "politty";
|
|
140
|
+
*
|
|
141
|
+
* const command = defineCommand({
|
|
142
|
+
* name: "my-cli",
|
|
143
|
+
* run: () => console.log("Hello!"),
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* runMain(command, { version: "1.0.0" });
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
declare function runMain(command: AnyCommand, options?: MainOptions): Promise<never>;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/output/help-generator.d.ts
|
|
152
|
+
/**
|
|
153
|
+
* Descriptions for built-in options
|
|
154
|
+
*/
|
|
155
|
+
interface BuiltinOptionDescriptions {
|
|
156
|
+
/** Description for --help option */
|
|
157
|
+
help?: string;
|
|
158
|
+
/** Description for --help-all option */
|
|
159
|
+
helpAll?: string;
|
|
160
|
+
/** Description for --version option */
|
|
161
|
+
version?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Context for command hierarchy
|
|
165
|
+
*/
|
|
166
|
+
interface CommandContext {
|
|
167
|
+
/** Full command path (e.g., ["config", "get"]) */
|
|
168
|
+
commandPath?: string[] | undefined;
|
|
169
|
+
/** Root command name */
|
|
170
|
+
rootName?: string | undefined;
|
|
171
|
+
/** Root command version */
|
|
172
|
+
rootVersion?: string | undefined;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Options for help generation
|
|
176
|
+
*/
|
|
177
|
+
interface HelpOptions {
|
|
178
|
+
/** Show subcommand list */
|
|
179
|
+
showSubcommands?: boolean | undefined;
|
|
180
|
+
/** Show subcommand options */
|
|
181
|
+
showSubcommandOptions?: boolean | undefined;
|
|
182
|
+
/** Custom descriptions for built-in options */
|
|
183
|
+
descriptions?: BuiltinOptionDescriptions | undefined;
|
|
184
|
+
/** Command hierarchy context */
|
|
185
|
+
context?: CommandContext | undefined;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Generate help text for a command
|
|
189
|
+
*
|
|
190
|
+
* @param command - The command to generate help for
|
|
191
|
+
* @param options - Help generation options
|
|
192
|
+
* @returns Formatted help text
|
|
193
|
+
*/
|
|
194
|
+
declare function generateHelp(command: AnyCommand, options: HelpOptions): string;
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/output/logger.d.ts
|
|
197
|
+
/**
|
|
198
|
+
* Enable or disable color output programmatically
|
|
199
|
+
*/
|
|
200
|
+
declare function setColorEnabled(enabled: boolean): void;
|
|
201
|
+
/**
|
|
202
|
+
* Check if color output is currently enabled
|
|
203
|
+
*/
|
|
204
|
+
declare function isColorEnabled(): boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Semantic style functions for inline text styling
|
|
207
|
+
*/
|
|
208
|
+
declare const styles: {
|
|
209
|
+
success: (text: string) => string;
|
|
210
|
+
error: (text: string) => string;
|
|
211
|
+
warning: (text: string) => string;
|
|
212
|
+
info: (text: string) => string;
|
|
213
|
+
bold: (text: string) => string;
|
|
214
|
+
dim: (text: string) => string;
|
|
215
|
+
italic: (text: string) => string;
|
|
216
|
+
underline: (text: string) => string;
|
|
217
|
+
red: (text: string) => string;
|
|
218
|
+
green: (text: string) => string;
|
|
219
|
+
yellow: (text: string) => string;
|
|
220
|
+
blue: (text: string) => string;
|
|
221
|
+
magenta: (text: string) => string;
|
|
222
|
+
cyan: (text: string) => string;
|
|
223
|
+
white: (text: string) => string;
|
|
224
|
+
gray: (text: string) => string;
|
|
225
|
+
command: (text: string) => string;
|
|
226
|
+
commandName: (text: string) => string;
|
|
227
|
+
option: (text: string) => string;
|
|
228
|
+
optionName: (text: string) => string;
|
|
229
|
+
placeholder: (text: string) => string;
|
|
230
|
+
defaultValue: (text: string) => string;
|
|
231
|
+
required: (text: string) => string;
|
|
232
|
+
description: (text: string) => string;
|
|
233
|
+
sectionHeader: (text: string) => string;
|
|
234
|
+
version: (text: string) => string;
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Standardized symbols for CLI output
|
|
238
|
+
*/
|
|
239
|
+
declare const symbols: {
|
|
240
|
+
success: string;
|
|
241
|
+
error: string;
|
|
242
|
+
warning: string;
|
|
243
|
+
info: string;
|
|
244
|
+
bullet: string;
|
|
245
|
+
arrow: string;
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Logger for CLI output
|
|
249
|
+
*/
|
|
250
|
+
declare const logger: {
|
|
251
|
+
/**
|
|
252
|
+
* Log informational message
|
|
253
|
+
*/
|
|
254
|
+
info(message: string): void;
|
|
255
|
+
/**
|
|
256
|
+
* Log success message
|
|
257
|
+
*/
|
|
258
|
+
success(message: string): void;
|
|
259
|
+
/**
|
|
260
|
+
* Log warning message
|
|
261
|
+
*/
|
|
262
|
+
warn(message: string): void;
|
|
263
|
+
/**
|
|
264
|
+
* Log error message
|
|
265
|
+
*/
|
|
266
|
+
error(message: string): void;
|
|
267
|
+
/**
|
|
268
|
+
* Log raw message without prefix
|
|
269
|
+
*/
|
|
270
|
+
log(message: string): void;
|
|
271
|
+
/**
|
|
272
|
+
* Log empty line
|
|
273
|
+
*/
|
|
274
|
+
newline(): void;
|
|
275
|
+
/**
|
|
276
|
+
* Log debug message with dim color
|
|
277
|
+
*/
|
|
278
|
+
debug(message: string): void;
|
|
279
|
+
};
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/validator/validation-errors.d.ts
|
|
282
|
+
/**
|
|
283
|
+
* Error thrown when positional argument configuration is invalid
|
|
284
|
+
*/
|
|
285
|
+
declare class PositionalConfigError extends Error {
|
|
286
|
+
constructor(message: string);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Error thrown when a reserved alias is used
|
|
290
|
+
*/
|
|
291
|
+
declare class ReservedAliasError extends Error {
|
|
292
|
+
constructor(message: string);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Error thrown when duplicate field names are detected
|
|
296
|
+
*/
|
|
297
|
+
declare class DuplicateFieldError extends Error {
|
|
298
|
+
constructor(message: string);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Error thrown when duplicate aliases are detected
|
|
302
|
+
*/
|
|
303
|
+
declare class DuplicateAliasError extends Error {
|
|
304
|
+
constructor(message: string);
|
|
305
|
+
}
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/validator/command-validator.d.ts
|
|
308
|
+
/**
|
|
309
|
+
* Error detail for command validation
|
|
310
|
+
*/
|
|
311
|
+
interface CommandValidationError {
|
|
312
|
+
/** Path to the command (e.g., ["cli", "build", "watch"]) */
|
|
313
|
+
commandPath: string[];
|
|
314
|
+
/** Error type */
|
|
315
|
+
type: "duplicate_field" | "duplicate_alias" | "positional_config" | "reserved_alias";
|
|
316
|
+
/** Error message */
|
|
317
|
+
message: string;
|
|
318
|
+
/** Related field name (if applicable) */
|
|
319
|
+
field?: string;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Result of command validation
|
|
323
|
+
*/
|
|
324
|
+
type CommandValidationResult = {
|
|
325
|
+
valid: true;
|
|
326
|
+
} | {
|
|
327
|
+
valid: false;
|
|
328
|
+
errors: CommandValidationError[];
|
|
329
|
+
};
|
|
330
|
+
/**
|
|
331
|
+
* Options for validateCommand
|
|
332
|
+
*/
|
|
333
|
+
interface ValidateCommandOptions {
|
|
334
|
+
/** Starting command path (for nested validation) */
|
|
335
|
+
commandPath?: string[];
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Validate that no duplicate field names exist
|
|
339
|
+
*
|
|
340
|
+
* @param extracted - Extracted fields from schema
|
|
341
|
+
* @throws {DuplicateFieldError} If duplicate field names are found
|
|
342
|
+
*/
|
|
343
|
+
declare function validateDuplicateFields(extracted: ExtractedFields): void;
|
|
344
|
+
/**
|
|
345
|
+
* Validate that no duplicate aliases exist
|
|
346
|
+
*
|
|
347
|
+
* Also checks for conflicts between aliases and field names
|
|
348
|
+
*
|
|
349
|
+
* @param extracted - Extracted fields from schema
|
|
350
|
+
* @throws {DuplicateAliasError} If duplicate aliases are found or alias conflicts with field name
|
|
351
|
+
*/
|
|
352
|
+
declare function validateDuplicateAliases(extracted: ExtractedFields): void;
|
|
353
|
+
/**
|
|
354
|
+
* Validate positional argument configuration
|
|
355
|
+
*
|
|
356
|
+
* Rules:
|
|
357
|
+
* - Array positional arguments must be the last positional
|
|
358
|
+
* - No positional arguments can follow an array positional
|
|
359
|
+
* - Required positional arguments cannot follow optional positional arguments
|
|
360
|
+
* - Array positional and optional positional cannot be used together (ambiguous parsing)
|
|
361
|
+
*
|
|
362
|
+
* @param extracted - Extracted fields from schema
|
|
363
|
+
* @throws {PositionalConfigError} If configuration is invalid
|
|
364
|
+
*/
|
|
365
|
+
declare function validatePositionalConfig(extracted: ExtractedFields): void;
|
|
366
|
+
/**
|
|
367
|
+
* Validate that no reserved aliases are used without explicit override
|
|
368
|
+
*
|
|
369
|
+
* Reserved aliases:
|
|
370
|
+
* - 'h' is reserved for --help
|
|
371
|
+
* - 'H' is reserved for --help-all
|
|
372
|
+
*
|
|
373
|
+
* Users can override these by setting overrideBuiltinAlias: true
|
|
374
|
+
*
|
|
375
|
+
* @param extracted - Extracted fields from schema
|
|
376
|
+
* @param _hasSubCommands - Whether the command has subcommands (reserved for future use)
|
|
377
|
+
* @throws {ReservedAliasError} If a reserved alias is used without override flag
|
|
378
|
+
*/
|
|
379
|
+
declare function validateReservedAliases(extracted: ExtractedFields, _hasSubCommands: boolean): void;
|
|
380
|
+
/**
|
|
381
|
+
* Validate a command and all its subcommands recursively
|
|
382
|
+
*
|
|
383
|
+
* This function collects all validation errors without throwing,
|
|
384
|
+
* making it suitable for test assertions.
|
|
385
|
+
*
|
|
386
|
+
* @param command - The command to validate
|
|
387
|
+
* @param options - Validation options
|
|
388
|
+
* @returns Validation result with all errors collected
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```ts
|
|
392
|
+
* const result = await validateCommand(myCommand);
|
|
393
|
+
* if (!result.valid) {
|
|
394
|
+
* console.error(result.errors);
|
|
395
|
+
* }
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
398
|
+
declare function validateCommand(command: AnyCommand, options?: ValidateCommandOptions): Promise<CommandValidationResult>;
|
|
399
|
+
/**
|
|
400
|
+
* Format command validation errors for display
|
|
401
|
+
*
|
|
402
|
+
* @param errors - Array of validation errors
|
|
403
|
+
* @returns Formatted error message
|
|
404
|
+
*/
|
|
405
|
+
declare function formatCommandValidationErrors(errors: CommandValidationError[]): string;
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/validator/zod-validator.d.ts
|
|
408
|
+
/**
|
|
409
|
+
* Validation error details
|
|
410
|
+
*/
|
|
411
|
+
interface ValidationError {
|
|
412
|
+
/** Path to the invalid field */
|
|
413
|
+
path: string[];
|
|
414
|
+
/** Error message */
|
|
415
|
+
message: string;
|
|
416
|
+
/** Zod error code */
|
|
417
|
+
code: string;
|
|
418
|
+
/** Value that was received */
|
|
419
|
+
received?: unknown | undefined;
|
|
420
|
+
/** Expected type or value */
|
|
421
|
+
expected?: string | undefined;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Validation result
|
|
425
|
+
*/
|
|
426
|
+
type ValidationResult<T> = {
|
|
427
|
+
success: true;
|
|
428
|
+
data: T;
|
|
429
|
+
} | {
|
|
430
|
+
success: false;
|
|
431
|
+
errors: ValidationError[];
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* Format validation errors for display
|
|
435
|
+
*/
|
|
436
|
+
declare function formatValidationErrors(errors: ValidationError[]): string;
|
|
437
|
+
//#endregion
|
|
438
|
+
export { type AnyCommand, type ArgMeta, type ArgsSchema, type BuiltinOptionDescriptions, type CleanupContext, type CollectedLogs, type Command, type CommandBase, type CommandContext, type CommandValidationError, type CommandValidationResult, DuplicateAliasError, DuplicateFieldError, type Example, type ExtractedFields, type HelpOptions, type LogEntry, type LogLevel, type LogStream, type Logger, type MainOptions, type NonRunnableCommand, PositionalConfigError, ReservedAliasError, type ResolvedFieldMeta, type RunCommandOptions, type RunResult, type RunResultFailure, type RunResultSuccess, type RunnableCommand, type SetupContext, type SubCommandValue, type SubCommandsRecord, type UnknownKeysMode, type ValidationError, type ValidationResult, arg, defineCommand, extractFields, formatCommandValidationErrors, formatValidationErrors, generateHelp, getUnknownKeysMode, isColorEnabled, logger, runCommand, runMain, setColorEnabled, styles, symbols, toKebabCase, validateCommand, validateDuplicateAliases, validateDuplicateFields, validatePositionalConfig, validateReservedAliases };
|
|
439
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/core/command.ts","../src/core/runner.ts","../src/output/help-generator.ts","../src/output/logger.ts","../src/validator/validation-errors.ts","../src/validator/command-validator.ts","../src/validator/zod-validator.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAQqB,KAKhB,SAAA,CAAA,WAAS,CAAA,GAAgB,WAAhB,SAAoC,CAAA,CAAE,OAAtC,GACV,CAAA,CAAE,KADQ,CACF,WADE,CAAA,GAEV,MAFU,CAAA,MAAA,EAAA,KAAA,CAAA;;;;;;UASJ,mBAPA,CAAA,oBAOwC,UAPxC,GAAA,SAAA,EAAA,OAAA,CAAA,CAAA;EAOA,IAAA,EAAA,MAAA;EAAwC,WAAA,CAAA,EAAA,MAAA;EAGzC,IAAA,CAAA,EAAA,WAAA;EACO,WAAA,CAAA,EAAA,iBAAA;EACsB,KAAA,CAAA,EAAA,CAAA,OAAA,EAAA;IAAV,IAAA,EAAA,SAAA,CAAU,WAAV,CAAA;EAAoC,CAAA,EAAA,GAAA,IAAA,GAAA,OAAA,CAAA,IAAA,CAAA;EACvC,GAAA,CAAA,EAAA,CAAA,IAAA,EAAV,SAAU,CAAA,WAAA,CAAA,EAAA,GAAiB,OAAjB;EAAV,OAAA,CAAA,EAAA,CAAA,OAAA,EAAA;IAA2B,IAAA,EAEhC,SAFgC,CAEtB,WAFsB,CAAA;IAEtB,KAAA,CAAA,EACR,KADQ,GAAA,SAAA;EAAV,CAAA,EAAA,GAAA,IAAA,GAEK,OAFL,CAAA,IAAA,CAAA;EACE,KAAA,CAAA,EAAA,MAAA;EACG,QAAA,CAAA,EAEF,OAFE,EAAA;;;AAEK;;UAMV,cAGoB,CAAA,oBAFR,UAEQ,G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