convoker 0.2.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/error.d.ts CHANGED
@@ -1,844 +1,107 @@
1
- /**
2
- * Command action function.
3
- */
4
- declare type ActionFn<T extends Input> = (input: InferInput<T>) => void | Promise<void>;
5
-
6
- /**
7
- * A basic input type.
8
- */
9
- declare type BasicKind = "boolean" | "string" | "number" | "bigint";
10
-
11
- /**
12
- * A basic input type.
13
- */
14
- declare type BasicKind_2 = "boolean" | "string" | "number" | "bigint";
15
-
16
- /**
17
- * Builder for commands.
18
- */
19
- declare type Builder = (c: Command<any>) => Command<any> | void;
20
-
21
- /**
22
- * A command.
23
- */
24
- declare class Command<T extends Input = Input> {
25
- /**
26
- * The names (aliases) of this command.
27
- */
28
- $names: string[];
29
- /**
30
- * The description of this command.
31
- */
32
- $description: string | undefined;
33
- /**
34
- * The theme of this command
35
- */
36
- $theme: Theme | undefined;
37
- /**
38
- * The version of this command.
39
- */
40
- $version: string | undefined;
41
- /**
42
- * The children of this command.
43
- */
44
- $children: Map<string, CommandAlias>;
45
- /**
46
- * The parent of this command.
47
- */
48
- $parent: Command<any> | undefined;
49
- /**
50
- * If this command allows unknown options.
51
- */
52
- $allowUnknownOptions: boolean;
53
- /**
54
- * If you should be able to surpass the amount of positional arguments defined in the input.
55
- */
56
- $allowSurpassArgLimit: boolean;
57
- /**
58
- * The input this command takes.
59
- */
60
- $input: T;
61
- /**
62
- * The action function of this command.
63
- */
64
- $fn: ActionFn<T> | undefined;
65
- /**
66
- * The error handler of this command.
67
- */
68
- $errorFn: ErrorFn<T> | undefined;
69
- /**
70
- * Creates a new command.
71
- * @param names The names (aliases).
72
- * @param desc The description.
73
- * @param version The version.
74
- */
75
- constructor(names: string | string[], desc?: string, version?: string);
76
- /**
77
- * Adds a set of aliases to this command.
78
- * @param aliases The aliases to add.
79
- * @returns this
80
- */
81
- alias(...aliases: string[]): this;
82
- /**
83
- * Adds a description to this command.
84
- * @param desc The description.
85
- * @returns this
86
- */
87
- description(desc: string): this;
88
- /**
89
- * Adds a version to this command.
90
- * @param version The version.
91
- * @returns this
92
- */
93
- version(version: string): this;
94
- /**
95
- * Sets the input for this command.
96
- * @param version The input.
97
- * @returns this
98
- */
99
- input<TInput extends Input>(input: TInput): Command<TInput>;
100
- /**
101
- * Sets the action function for this command.
102
- * @param fn The action.
103
- * @returns this
104
- */
105
- action(fn: ActionFn<T>): this;
106
- /**
107
- * Sets the error function for this command.
108
- * @param fn The error handler.
109
- * @returns this
110
- */
111
- error(fn: ErrorFn<T>): this;
112
- /**
113
- * Adds an existing command to this.
114
- * @param command The command.
115
- * @returns this
116
- */
117
- add(command: Command<any>): this;
118
- /**
119
- * Creates a new subcommand and adds it.
120
- * @param names The aliases of the subcommand.
121
- * @param builder A builder to create the command.
122
- */
123
- subCommand(names: string | string[], builder: Builder): this;
124
- /**
125
- * Creates a new subcommand and adds it.
126
- * @param names The aliases of the subcommand.
127
- * @param desc The description of the subcommand.
128
- * @param version The version of the subcommand.
129
- */
130
- subCommand(names: string | string[], desc?: string, version?: string): Command<any>;
131
- /**
132
- * Allows unknown options.
133
- * @returns this
134
- */
135
- allowUnknownOptions(): this;
136
- /**
137
- * Parses a set of command-line arguments.
138
- * @param argv The arguments to parse.
139
- * @returns A parse result.
140
- */
141
- parse(argv: string[]): Promise<ParseResult<T>>;
142
- private buildInputMap;
143
- /**
144
- * Gets the full command path (name including parents).
145
- * @returns The full command path.
146
- */
147
- fullCommandPath(): string;
148
- /**
149
- * The default error screen.
150
- * @param errors The errors.
151
- */
152
- defaultErrorScreen(errors: Error[]): void;
153
- /**
154
- * Handles a set of errors.
155
- * @param errors The errors to handle.
156
- * @param input The parsed input, if possible.
157
- * @returns this
158
- */
159
- handleErrors(errors: Error[], input?: Partial<InferInput<T>>): Promise<this>;
160
- /**
161
- * Runs a command.
162
- * @param argv The arguments to run the command with. Defaults to your runtime's `argv` equivalent.
163
- * @returns this
164
- */
165
- run(argv?: string[]): Promise<this>;
166
- }
167
-
168
- /**
169
- * What the command is an alias for.
170
- */
171
- declare interface CommandAlias<T extends Input = Input> {
172
- /**
173
- * A pointer to the command.
174
- */
175
- command: Command<T>;
176
- /**
177
- * The name of the command this is an alias for.
178
- */
179
- alias?: string;
180
- }
181
-
182
- /**
183
- * A Convoker-related error. These are usually handled by default.
184
- */
185
- export declare class ConvokerError extends Error {
186
- /**
187
- * The command this error happened on.
188
- */
189
- command: Command<any>;
190
- /**
191
- * Creates a new Convoker error.
192
- * @param message The message.
193
- * @param command The command.
194
- */
195
- constructor(message: string, command: Command<any>);
196
- /**
197
- * Prints the error's message.
198
- */
199
- print(): void;
200
- }
201
-
202
- /**
203
- * A Convoker-related error. These are usually handled by default.
204
- */
205
- declare class ConvokerError_2 extends Error {
206
- /**
207
- * The command this error happened on.
208
- */
209
- command: Command<any>;
210
- /**
211
- * Creates a new Convoker error.
212
- * @param message The message.
213
- * @param command The command.
214
- */
215
- constructor(message: string, command: Command<any>);
216
- /**
217
- * Prints the error's message.
218
- */
219
- print(): void;
220
- }
221
-
222
- /**
223
- * Command error handler.
224
- */
225
- declare type ErrorFn<T extends Input> = (command: Command<T>, errors: Error[], input: Partial<InferInput<T>>) => void | Promise<void>;
226
-
227
- /**
228
- * When the user asks for help.
229
- */
230
- export declare class HelpAskedError extends ConvokerError {
231
- /**
232
- * Creates a new help asked error.
233
- * @param command The command.
234
- */
235
- constructor(command: Command<any>);
236
- }
237
-
238
- /**
239
- * Infers a TypeScript type from an option or positional.
240
- */
241
- declare type InferEntry<T> = T extends {
242
- $kind: infer TKind extends Kind;
243
- $required: infer Required;
244
- $list: infer List;
245
- } ? List extends true ? Required extends true ? TypeOf<TKind>[] : TypeOf<TKind>[] | undefined : Required extends true ? TypeOf<TKind> : TypeOf<TKind> | undefined : never;
246
-
247
- /**
248
- * Infers TypeScript types from an input object.
249
- */
250
- declare type InferInput<T extends Input> = {
251
- [K in keyof T]: InferEntry<T[K]>;
252
- };
253
-
254
- /**
255
- * An input object.
256
- */
257
- declare interface Input {
258
- [x: string]: Option_2<any, any, any> | Positional<any, any, any>;
259
- }
260
-
261
- /**
262
- * Thrown when the command fails to validate an input.
263
- */
264
- export declare class InputValidationError extends Error {
265
- /**
266
- * A list of messages.
267
- */
268
- messages: string[];
269
- /**
270
- * Creates a new input validation error.
271
- * @param messages The messages.
272
- */
273
- constructor(messages: string[]);
274
- }
275
-
276
- /**
277
- * An input type.
278
- */
279
- declare type Kind = BasicKind | StandardSchemaV1<any, any>;
280
-
281
- /**
282
- * An input type.
283
- */
284
- declare type Kind_2 = BasicKind_2 | StandardSchemaV1_2<any, any>;
285
-
286
- export declare class MissingRequiredArgumentError extends ConvokerError {
287
- /**
288
- * The argument key.
289
- */
290
- key: string;
291
- /**
292
- * The argument entry.
293
- */
294
- entry: Positional_2<any, any, any>;
295
- /**
296
- * Creates a new missing required argument error.
297
- * @param command The command.
298
- * @param key The key.
299
- * @param entry The entry.
300
- */
301
- constructor(command: Command<any>, key: string, entry: Positional_2<any, any, any>);
302
- }
303
-
304
- /**
305
- * When a required option is missing.
306
- */
307
- export declare class MissingRequiredOptionError extends ConvokerError {
308
- /**
309
- * The option key.
310
- */
311
- key: string;
312
- /**
313
- * The option entry.
314
- */
315
- entry: Option_2_2<any, any, any>;
316
- /**
317
- * Creates a new missing required option error.
318
- * @param command The command.
319
- * @param key The key.
320
- * @param entry The entry.
321
- */
322
- constructor(command: Command<any>, key: string, entry: Option_2_2<any, any, any>);
323
- }
324
-
325
- /**
326
- * An option.
327
- */
328
- declare class Option_2<TKind extends Kind, TRequired extends boolean = true, TList extends boolean = false> {
329
- /**
330
- * The kind of this option.
331
- */
332
- $kind: TKind;
333
- /**
334
- * The aliases of this option.
335
- */
336
- $names: string[];
337
- /**
338
- * The description of this option.
339
- */
340
- $description: string | undefined;
341
- /**
342
- * The default value of this option.
343
- */
344
- $default: TypeOf<TKind> | undefined;
345
- /**
346
- * If this option is required.
347
- */
348
- $required: TRequired;
349
- /**
350
- * If this option is a list.
351
- */
352
- $list: TList;
353
- /**
354
- * A separator if this option is a list.
355
- */
356
- $separator: string | undefined;
357
- /**
358
- * Creates a new option.
359
- * @param kind The type of this option.
360
- * @param names The names of this option.
361
- */
362
- constructor(kind: TKind, names: string[]);
363
- /**
364
- * Makes this option a list.
365
- * @returns this
366
- */
367
- list(separator?: string): Option_2<TKind, TRequired, true>;
368
- /**
369
- * Makes this option required.
370
- * @returns this
371
- */
372
- required(): Option_2<TKind, true, TList>;
373
- /**
374
- * Makes this option optional.
375
- * @returns this
376
- */
377
- optional(): Option_2<TKind, false, TList>;
378
- /**
379
- * Sets a default value.
380
- * @param value The default value.
381
- * @returns this
382
- */
383
- default(value: TypeOf<TKind>): this;
384
- /**
385
- * Sets a description.
386
- * @param desc The description.
387
- * @returns this
388
- */
389
- description(desc: string): this;
390
- }
391
-
392
- /**
393
- * An option.
394
- */
395
- declare class Option_2_2<TKind extends Kind_2, TRequired extends boolean = true, TList extends boolean = false> {
396
- /**
397
- * The kind of this option.
398
- */
399
- $kind: TKind;
400
- /**
401
- * The aliases of this option.
402
- */
403
- $names: string[];
404
- /**
405
- * The description of this option.
406
- */
407
- $description: string | undefined;
408
- /**
409
- * The default value of this option.
410
- */
411
- $default: TypeOf_2<TKind> | undefined;
412
- /**
413
- * If this option is required.
414
- */
415
- $required: TRequired;
416
- /**
417
- * If this option is a list.
418
- */
419
- $list: TList;
420
- /**
421
- * A separator if this option is a list.
422
- */
423
- $separator: string | undefined;
424
- /**
425
- * Creates a new option.
426
- * @param kind The type of this option.
427
- * @param names The names of this option.
428
- */
429
- constructor(kind: TKind, names: string[]);
430
- /**
431
- * Makes this option a list.
432
- * @returns this
433
- */
434
- list(separator?: string): Option_2_2<TKind, TRequired, true>;
435
- /**
436
- * Makes this option required.
437
- * @returns this
438
- */
439
- required(): Option_2_2<TKind, true, TList>;
440
- /**
441
- * Makes this option optional.
442
- * @returns this
443
- */
444
- optional(): Option_2_2<TKind, false, TList>;
445
- /**
446
- * Sets a default value.
447
- * @param value The default value.
448
- * @returns this
449
- */
450
- default(value: TypeOf_2<TKind>): this;
451
- /**
452
- * Sets a description.
453
- * @param desc The description.
454
- * @returns this
455
- */
456
- description(desc: string): this;
457
- }
458
-
459
- /**
460
- * The result of the `Command.parse` function.
461
- */
462
- declare interface ParseResult<T extends Input> {
463
- /**
464
- * A pointer to the command to run.
465
- */
466
- command: Command<T>;
467
- /**
468
- * The input to pass into the command.
469
- */
470
- input: InferInput<T>;
471
- /**
472
- * Errors collected during parsing.
473
- */
474
- errors: ConvokerError_2[];
475
- /**
476
- * If this should result in displaying the version of the command.
477
- */
478
- isVersion: boolean;
479
- /**
480
- * If this should result in displaying a help screen.
481
- */
482
- isHelp: boolean;
483
- }
484
-
485
- /**
486
- * A positional argument.
487
- */
488
- declare class Positional<TKind extends Kind, TRequired extends boolean = true, TList extends boolean = false> {
489
- /**
490
- * The type of this argument.
491
- */
492
- $kind: TKind;
493
- /**
494
- * The default value of this argument.
495
- */
496
- $default: TypeOf<TKind> | undefined;
497
- /**
498
- * The description of this argument.
499
- */
500
- $description: string | undefined;
501
- /**
502
- * If this argument is required.
503
- */
504
- $required: TRequired;
505
- /**
506
- * If this argument is a list.
507
- */
508
- $list: TList;
509
- /**
510
- * Creates a new positional argument.
511
- * @param kind The positional argument.
512
- */
513
- constructor(kind: TKind);
514
- /**
515
- * Makes this argument a list.
516
- * @returns this
517
- */
518
- list(): Positional<TKind, TRequired, true>;
519
- /**
520
- * Makes this argument required.
521
- * @returns this
522
- */
523
- required(): Positional<TKind, true, TList>;
524
- /**
525
- * Makes this argument optional.
526
- * @returns this
527
- */
528
- optional(): Positional<TKind, false, TList>;
529
- /**
530
- * Sets a default value.
531
- * @param value The default value.
532
- * @returns this
533
- */
534
- default(value: TypeOf<TKind>): this;
535
- /**
536
- * Sets a description.
537
- * @param desc The description.
538
- * @returns this
539
- */
540
- description(desc: string): this;
541
- }
542
-
543
- /**
544
- * A positional argument.
545
- */
546
- declare class Positional_2<TKind extends Kind_2, TRequired extends boolean = true, TList extends boolean = false> {
547
- /**
548
- * The type of this argument.
549
- */
550
- $kind: TKind;
551
- /**
552
- * The default value of this argument.
553
- */
554
- $default: TypeOf_2<TKind> | undefined;
555
- /**
556
- * The description of this argument.
557
- */
558
- $description: string | undefined;
559
- /**
560
- * If this argument is required.
561
- */
562
- $required: TRequired;
563
- /**
564
- * If this argument is a list.
565
- */
566
- $list: TList;
567
- /**
568
- * Creates a new positional argument.
569
- * @param kind The positional argument.
570
- */
571
- constructor(kind: TKind);
572
- /**
573
- * Makes this argument a list.
574
- * @returns this
575
- */
576
- list(): Positional_2<TKind, TRequired, true>;
577
- /**
578
- * Makes this argument required.
579
- * @returns this
580
- */
581
- required(): Positional_2<TKind, true, TList>;
582
- /**
583
- * Makes this argument optional.
584
- * @returns this
585
- */
586
- optional(): Positional_2<TKind, false, TList>;
587
- /**
588
- * Sets a default value.
589
- * @param value The default value.
590
- * @returns this
591
- */
592
- default(value: TypeOf_2<TKind>): this;
593
- /**
594
- * Sets a description.
595
- * @param desc The description.
596
- * @returns this
597
- */
598
- description(desc: string): this;
599
- }
600
-
601
- /** The Standard Schema interface. */
602
- declare interface StandardSchemaV1<Input = unknown, Output = Input> {
603
- /** The Standard Schema properties. */
604
- readonly "~standard": StandardSchemaV1.Props<Input, Output>;
605
- }
606
-
607
- declare namespace StandardSchemaV1 {
608
- /** The Standard Schema properties interface. */
609
- interface Props<Input = unknown, Output = Input> {
610
- /** The version number of the standard. */
611
- readonly version: 1;
612
- /** The vendor name of the schema library. */
613
- readonly vendor: string;
614
- /** Validates unknown input values. */
615
- readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
616
- /** Inferred types associated with the schema. */
617
- readonly types?: Types<Input, Output> | undefined;
618
- }
619
- /** The result interface of the validate function. */
620
- type Result<Output> = SuccessResult<Output> | FailureResult;
621
- /** The result interface if validation succeeds. */
622
- interface SuccessResult<Output> {
623
- /** The typed output value. */
624
- readonly value: Output;
625
- /** The non-existent issues. */
626
- readonly issues?: undefined;
627
- }
628
- /** The result interface if validation fails. */
629
- interface FailureResult {
630
- /** The issues of failed validation. */
631
- readonly issues: ReadonlyArray<Issue>;
632
- }
633
- /** The issue interface of the failure output. */
634
- interface Issue {
635
- /** The error message of the issue. */
636
- readonly message: string;
637
- /** The path of the issue, if any. */
638
- readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
639
- }
640
- /** The path segment interface of the issue. */
641
- interface PathSegment {
642
- /** The key representing a path segment. */
643
- readonly key: PropertyKey;
644
- }
645
- /** The Standard Schema types interface. */
646
- interface Types<Input = unknown, Output = Input> {
647
- /** The input type of the schema. */
648
- readonly input: Input;
649
- /** The output type of the schema. */
650
- readonly output: Output;
651
- }
652
- /** Infers the input type of a Standard Schema. */
653
- type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
654
- /** Infers the output type of a Standard Schema. */
655
- type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
656
- }
657
-
658
- /** The Standard Schema interface. */
659
- declare interface StandardSchemaV1_2<Input = unknown, Output = Input> {
660
- /** The Standard Schema properties. */
661
- readonly "~standard": StandardSchemaV1_2.Props<Input, Output>;
662
- }
663
-
664
- declare namespace StandardSchemaV1_2 {
665
- /** The Standard Schema properties interface. */
666
- interface Props<Input = unknown, Output = Input> {
667
- /** The version number of the standard. */
668
- readonly version: 1;
669
- /** The vendor name of the schema library. */
670
- readonly vendor: string;
671
- /** Validates unknown input values. */
672
- readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
673
- /** Inferred types associated with the schema. */
674
- readonly types?: Types<Input, Output> | undefined;
675
- }
676
- /** The result interface of the validate function. */
677
- type Result<Output> = SuccessResult<Output> | FailureResult;
678
- /** The result interface if validation succeeds. */
679
- interface SuccessResult<Output> {
680
- /** The typed output value. */
681
- readonly value: Output;
682
- /** The non-existent issues. */
683
- readonly issues?: undefined;
684
- }
685
- /** The result interface if validation fails. */
686
- interface FailureResult {
687
- /** The issues of failed validation. */
688
- readonly issues: ReadonlyArray<Issue>;
689
- }
690
- /** The issue interface of the failure output. */
691
- interface Issue {
692
- /** The error message of the issue. */
693
- readonly message: string;
694
- /** The path of the issue, if any. */
695
- readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
696
- }
697
- /** The path segment interface of the issue. */
698
- interface PathSegment {
699
- /** The key representing a path segment. */
700
- readonly key: PropertyKey;
701
- }
702
- /** The Standard Schema types interface. */
703
- interface Types<Input = unknown, Output = Input> {
704
- /** The input type of the schema. */
705
- readonly input: Input;
706
- /** The output type of the schema. */
707
- readonly output: Output;
708
- }
709
- /** Infers the input type of a Standard Schema. */
710
- type InferInput<Schema extends StandardSchemaV1_2> = NonNullable<Schema["~standard"]["types"]>["input"];
711
- /** Infers the output type of a Standard Schema. */
712
- type InferOutput<Schema extends StandardSchemaV1_2> = NonNullable<Schema["~standard"]["types"]>["output"];
713
- }
714
-
715
- /**
716
- * A theme.
717
- */
718
- declare interface Theme {
719
- /**
720
- * Wraps a string in a background ANSI code.
721
- * @param a The string to wrap.
722
- */
723
- background?(a: string): string;
724
- /**
725
- * Wraps a string in a foreground ANSI code.
726
- * @param a The string to wrap.
727
- */
728
- foreground?(a: string): string;
729
- /**
730
- * Wraps a string in a primary ANSI code.
731
- * @param a The string to wrap.
732
- */
733
- primary(a: string): string;
734
- /**
735
- * Wraps a string in a secondary ANSI code.
736
- * @param a The string to wrap.
737
- */
738
- secondary(a: string): string;
739
- /**
740
- * Wraps a string in a accent ANSI code.
741
- * @param a The string to wrap.
742
- */
743
- accent?(a: string): string;
744
- /**
745
- * Wraps a string in a success ANSI code.
746
- * @param a The string to wrap.
747
- */
748
- success(a: string): string;
749
- /**
750
- * Wraps a string in a warning ANSI code.
751
- * @param a The string to wrap.
752
- */
753
- warning(a: string): string;
754
- /**
755
- * Wraps a string in a error ANSI code.
756
- * @param a The string to wrap.
757
- */
758
- error(a: string): string;
759
- /**
760
- * Wraps a string in a info ANSI code.
761
- * @param a The string to wrap.
762
- */
763
- info?(a: string): string;
764
- /**
765
- * Set of symbols for logging.
766
- */
767
- symbols?: {
768
- /**
769
- * Success message symbol.
770
- */
771
- success: string;
772
- /**
773
- * Error message symbol.
774
- */
775
- error: string;
776
- /**
777
- * Warning message symbol.
778
- */
779
- warning: string;
780
- /**
781
- * Information message symbol.
782
- */
783
- info?: string;
784
- };
785
- /**
786
- * Optional styles.
787
- */
788
- styles?: {
789
- /**
790
- * Wraps a string in a bold ANSI code.
791
- * @param a The string to wrap.
792
- */
793
- bold?(a: string): string;
794
- /**
795
- * Wraps a string in an italic ANSI code.
796
- * @param a The string to wrap.
797
- */
798
- italic?(a: string): string;
799
- /**
800
- * Wraps a string in an underline ANSI code.
801
- * @param a The string to wrap.
802
- */
803
- underline?(a: string): string;
804
- };
805
- }
806
-
807
- /**
808
- * When you pass too many arguments.
809
- */
810
- export declare class TooManyArgumentsError extends ConvokerError {
811
- /**
812
- * Creates a new too many arguments error.
813
- * @param command The command.
814
- */
815
- constructor(command: Command<any>);
816
- }
817
-
818
- /**
819
- * Converts a Kind to a TypeScript type.
820
- */
821
- declare type TypeOf<T extends Kind> = T extends StandardSchemaV1<any, infer Out> ? Out : T extends "boolean" ? boolean : T extends "string" ? string : T extends "number" ? number : T extends "bigint" ? bigint : never;
822
-
823
- /**
824
- * Converts a Kind to a TypeScript type.
825
- */
826
- declare type TypeOf_2<T extends Kind_2> = T extends StandardSchemaV1_2<any, infer Out> ? Out : T extends "boolean" ? boolean : T extends "string" ? string : T extends "number" ? number : T extends "bigint" ? bigint : never;
827
-
828
- /**
829
- * When you pass an unknown option, when unknown options aren't allowed.
830
- */
831
- export declare class UnknownOptionError extends ConvokerError {
832
- /**
833
- * The option key.
834
- */
835
- key: string;
836
- /**
837
- * Creates a new unknown option error.
838
- * @param command The command.
839
- * @param key The key.
840
- */
841
- constructor(command: Command<any>, key: string);
842
- }
843
-
844
- export { }
1
+ import type { Command } from "./command";
2
+ import type { Option, Positional } from "./input";
3
+ /**
4
+ * Thrown when the command fails to validate an input.
5
+ */
6
+ export declare class InputValidationError extends Error {
7
+ /**
8
+ * A list of messages.
9
+ */
10
+ messages: string[];
11
+ /**
12
+ * Creates a new input validation error.
13
+ * @param messages The messages.
14
+ */
15
+ constructor(messages: string[]);
16
+ }
17
+ /**
18
+ * A Convoker-related error. These are usually handled by default.
19
+ */
20
+ export declare class ConvokerError extends Error {
21
+ /**
22
+ * The command this error happened on.
23
+ */
24
+ command: Command<any>;
25
+ /**
26
+ * Creates a new Convoker error.
27
+ * @param message The message.
28
+ * @param command The command.
29
+ */
30
+ constructor(message: string, command: Command<any>);
31
+ /**
32
+ * Prints the error's message.
33
+ */
34
+ print(): void;
35
+ }
36
+ /**
37
+ * When the user asks for help.
38
+ */
39
+ export declare class HelpAskedError extends ConvokerError {
40
+ /**
41
+ * Creates a new help asked error.
42
+ * @param command The command.
43
+ */
44
+ constructor(command: Command<any>);
45
+ }
46
+ /**
47
+ * When you pass too many arguments.
48
+ */
49
+ export declare class TooManyArgumentsError extends ConvokerError {
50
+ /**
51
+ * Creates a new too many arguments error.
52
+ * @param command The command.
53
+ */
54
+ constructor(command: Command<any>);
55
+ }
56
+ /**
57
+ * When you pass an unknown option, when unknown options aren't allowed.
58
+ */
59
+ export declare class UnknownOptionError extends ConvokerError {
60
+ /**
61
+ * The option key.
62
+ */
63
+ key: string;
64
+ /**
65
+ * Creates a new unknown option error.
66
+ * @param command The command.
67
+ * @param key The key.
68
+ */
69
+ constructor(command: Command<any>, key: string);
70
+ }
71
+ /**
72
+ * When a required option is missing.
73
+ */
74
+ export declare class MissingRequiredOptionError extends ConvokerError {
75
+ /**
76
+ * The option key.
77
+ */
78
+ key: string;
79
+ /**
80
+ * The option entry.
81
+ */
82
+ entry: Option<any, any, any>;
83
+ /**
84
+ * Creates a new missing required option error.
85
+ * @param command The command.
86
+ * @param key The key.
87
+ * @param entry The entry.
88
+ */
89
+ constructor(command: Command<any>, key: string, entry: Option<any, any, any>);
90
+ }
91
+ export declare class MissingRequiredArgumentError extends ConvokerError {
92
+ /**
93
+ * The argument key.
94
+ */
95
+ key: string;
96
+ /**
97
+ * The argument entry.
98
+ */
99
+ entry: Positional<any, any, any>;
100
+ /**
101
+ * Creates a new missing required argument error.
102
+ * @param command The command.
103
+ * @param key The key.
104
+ * @param entry The entry.
105
+ */
106
+ constructor(command: Command<any>, key: string, entry: Positional<any, any, any>);
107
+ }