cli-nano 1.1.0 → 1.1.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.
@@ -1,84 +0,0 @@
1
- //#region src/interfaces.d.ts
2
- interface ArgumentOptions {
3
- /** option type */
4
- type?: 'string' | 'boolean' | 'number' | 'array';
5
- /** description of the flag option */
6
- description: string;
7
- /** defaults to undefined, provide shorter alias as command options */
8
- alias?: string;
9
- /** default value for the option if not provided */
10
- default?: any;
11
- /** defaults to false, is the option required? */
12
- required?: boolean;
13
- }
14
- interface PositionalArgument {
15
- /** positional argument name (it will be displayed in the help docs) */
16
- name: string;
17
- /** positional argument description */
18
- description: string;
19
- /** postional argument type */
20
- type?: 'string' | 'boolean' | 'number' | 'array';
21
- /** defaults to false, allows multiple values for this positional argument */
22
- variadic?: boolean;
23
- /** default value for the option if not provided */
24
- default?: any;
25
- /** defaults to false, is the positional argument required? */
26
- required?: boolean;
27
- }
28
- interface CommandOptions {
29
- /** command name, used in the help docs */
30
- name: string;
31
- /** command description */
32
- description: string;
33
- /** list of positional arguments */
34
- positionals?: readonly PositionalArgument[];
35
- }
36
- /** CLI options */
37
- interface Config {
38
- /** CLI definition */
39
- command: CommandOptions;
40
- /** option name length (w/wo alias) shown in the help (defaults to 20) */
41
- helpOptLength?: number;
42
- /** description length shown in the help (defaults to 65) */
43
- helpDescLength?: number;
44
- /** CLI list of flag options */
45
- options: Record<string, ArgumentOptions>;
46
- /** CLI or package version */
47
- version?: string;
48
- }
49
- /** Utility type to map ArgumentOptions/PositionalArgument to their value type */
50
- type ArgValueType<T extends {
51
- type?: string;
52
- default?: any;
53
- variadic?: boolean;
54
- required?: boolean;
55
- }> = T['type'] extends 'boolean' ? boolean : T['type'] extends 'number' ? number : T['type'] extends 'array' ? T extends {
56
- variadic: true;
57
- } ? T extends {
58
- required: true;
59
- } ? [string, ...string[]] : string[] : string | string[] : T['type'] extends 'string' ? T extends {
60
- variadic: true;
61
- } ? T extends {
62
- required: true;
63
- } ? [string, ...string[]] : string[] : string : T['type'] extends undefined ? T extends {
64
- variadic: true;
65
- } ? T extends {
66
- required: true;
67
- } ? [string, ...string[]] : string[] : string : T['default'] extends undefined ? string : T['default'];
68
- /** Helper to get required keys */
69
- type RequiredKeys<T> = { [K in keyof T]: T[K] extends {
70
- required: true;
71
- } ? K : never }[keyof T];
72
- /** Helper to get optional keys */
73
- type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>;
74
- /** Map options record to an object type with required/optional properties */
75
- type OptionsToObject<T extends Record<string, any>> = { [K in RequiredKeys<T>]: ArgValueType<T[K]> } & { [K in OptionalKeys<T>]?: ArgValueType<T[K]> };
76
- /** Map positionals array to an object type with required/optional properties */
77
- type PositionalsToObject<T extends readonly PositionalArgument[] | undefined> = T extends readonly [infer P, ...infer Rest] ? P extends PositionalArgument ? (P['required'] extends true ? { [K in P['name']]: ArgValueType<P> } : { [K in P['name']]?: ArgValueType<P> }) & PositionalsToObject<Rest extends readonly PositionalArgument[] ? Rest : []> : PositionalsToObject<Rest extends readonly PositionalArgument[] ? Rest : []> : {
78
- [key: string]: never;
79
- };
80
- /** The full result type for parseArgs */
81
- type ArgsResult<C extends Config> = PositionalsToObject<C['command']['positionals']> & OptionsToObject<C['options']>;
82
- //#endregion
83
- export { ArgValueType, ArgsResult, ArgumentOptions, CommandOptions, Config, OptionsToObject, PositionalArgument, PositionalsToObject };
84
- //# sourceMappingURL=interfaces-CqSzltdU.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces-CqSzltdU.d.ts","names":[],"sources":["../src/interfaces.ts"],"sourcesContent":[],"mappings":";UAAiB,eAAA;EAAA;EAiBA,IAAA,CAAA,EAAA,QAAA,GAAA,SAAkB,GAAA,QAAA,GAAA,OAAA;EAoBlB;EAYA,WAAM,EAAA,MAAA;EAAA;EAAA,KAEZ,CAAA,EAAA,MAAA;EAAc;EASgB,OAA9B,CAAA,EAAA,GAAA;EAAM;EAOL,QAAA,CA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