bob-core 3.0.0-beta.7 → 3.0.0-beta.9
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/cjs/HelpFlag.d.ts +3 -5
- package/dist/cjs/args/index.d.ts +32 -35
- package/dist/cjs/flags/boolean.d.ts +3 -5
- package/dist/cjs/flags/directory.d.ts +8 -8
- package/dist/cjs/flags/file.d.ts +8 -8
- package/dist/cjs/flags/index.d.ts +35 -40
- package/dist/cjs/flags/number.d.ts +10 -9
- package/dist/cjs/flags/string.d.ts +3 -5
- package/dist/cjs/flags/url.d.ts +3 -5
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/lib/types.d.ts +3 -5
- package/dist/esm/HelpFlag.d.ts +3 -5
- package/dist/esm/args/index.d.ts +32 -35
- package/dist/esm/flags/boolean.d.ts +3 -5
- package/dist/esm/flags/directory.d.ts +8 -8
- package/dist/esm/flags/file.d.ts +8 -8
- package/dist/esm/flags/index.d.ts +35 -40
- package/dist/esm/flags/number.d.ts +10 -9
- package/dist/esm/flags/string.d.ts +3 -5
- package/dist/esm/flags/url.d.ts +3 -5
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/types.d.ts +3 -5
- package/package.json +1 -1
package/dist/cjs/HelpFlag.d.ts
CHANGED
|
@@ -4,19 +4,17 @@ export declare const HelpCommandFlag: {
|
|
|
4
4
|
} & {
|
|
5
5
|
parse: (input: any, opts: FlagOpts<any, import('./lib/types.js').CustomOptions>) => boolean;
|
|
6
6
|
type?: import('./lib/types.js').FlagKind;
|
|
7
|
-
ask?: (opts: FlagOpts) => Promise<any
|
|
7
|
+
ask?: ((opts: FlagOpts<any, import('./lib/types.js').CustomOptions>) => Promise<any>) | undefined;
|
|
8
8
|
description?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
default?: boolean | boolean[] | (() => boolean | boolean[] | null) | (() => Promise<boolean | boolean[] | null>) | null | undefined;
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
help?: string;
|
|
13
13
|
alias?: string | readonly string[];
|
|
14
|
-
handler?: ((value: boolean, opts: FlagOpts) => {
|
|
14
|
+
handler?: ((value: boolean, opts: FlagOpts<any, import('./lib/types.js').CustomOptions>) => {
|
|
15
15
|
shouldStop: boolean;
|
|
16
16
|
} | void) | undefined;
|
|
17
|
-
} &
|
|
18
|
-
parse?: ((input: any, opts: FlagOpts<any, import('./lib/types.js').CustomOptions>) => boolean) | undefined;
|
|
19
|
-
} & {
|
|
17
|
+
} & Partial<FlagDefinition<boolean, import('./lib/types.js').CustomOptions>> & {
|
|
20
18
|
readonly alias: readonly ["h"];
|
|
21
19
|
readonly description: "Displays help information about the command";
|
|
22
20
|
readonly handler: (value: boolean, opts: FlagOpts) => {
|
package/dist/cjs/args/index.d.ts
CHANGED
|
@@ -12,19 +12,17 @@ export declare const Args: {
|
|
|
12
12
|
} & {
|
|
13
13
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => string;
|
|
14
14
|
type?: import('../index.js').FlagKind;
|
|
15
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
15
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
16
16
|
description?: string;
|
|
17
17
|
required?: boolean;
|
|
18
18
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
19
19
|
multiple?: boolean;
|
|
20
20
|
help?: string;
|
|
21
21
|
alias?: string | readonly string[];
|
|
22
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts) => {
|
|
22
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
23
23
|
shouldStop: boolean;
|
|
24
24
|
} | void) | undefined;
|
|
25
|
-
} &
|
|
26
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => string) | undefined;
|
|
27
|
-
} & O;
|
|
25
|
+
} & Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions>> & O;
|
|
28
26
|
number: <const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
29
27
|
min?: number;
|
|
30
28
|
max?: number;
|
|
@@ -37,25 +35,26 @@ export declare const Args: {
|
|
|
37
35
|
max?: number;
|
|
38
36
|
}>) => number;
|
|
39
37
|
type?: import('../index.js').FlagKind;
|
|
40
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
38
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
39
|
+
min?: number;
|
|
40
|
+
max?: number;
|
|
41
|
+
}>) => Promise<any>) | undefined;
|
|
41
42
|
description?: string;
|
|
42
43
|
required?: boolean;
|
|
43
44
|
default?: number | number[] | (() => number | number[] | null) | (() => Promise<number | number[] | null>) | null | undefined;
|
|
44
45
|
multiple?: boolean;
|
|
45
46
|
help?: string;
|
|
46
47
|
alias?: string | readonly string[];
|
|
47
|
-
handler?: ((value: number, opts: import('../index.js').FlagOpts
|
|
48
|
+
handler?: ((value: number, opts: import('../index.js').FlagOpts<any, {
|
|
49
|
+
min?: number;
|
|
50
|
+
max?: number;
|
|
51
|
+
}>) => {
|
|
48
52
|
shouldStop: boolean;
|
|
49
53
|
} | void) | undefined;
|
|
50
|
-
} &
|
|
54
|
+
} & Partial<import('../index.js').FlagDefinition<number, {
|
|
51
55
|
min?: number;
|
|
52
56
|
max?: number;
|
|
53
|
-
}
|
|
54
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
55
|
-
min?: number;
|
|
56
|
-
max?: number;
|
|
57
|
-
}>) => number) | undefined;
|
|
58
|
-
} & O;
|
|
57
|
+
}>> & O;
|
|
59
58
|
option: typeof optionFlag;
|
|
60
59
|
file: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
61
60
|
exists?: boolean;
|
|
@@ -66,23 +65,23 @@ export declare const Args: {
|
|
|
66
65
|
exists?: boolean;
|
|
67
66
|
}>) => string;
|
|
68
67
|
type?: import('../index.js').FlagKind;
|
|
69
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
68
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
69
|
+
exists?: boolean;
|
|
70
|
+
}>) => Promise<any>) | undefined;
|
|
70
71
|
description?: string;
|
|
71
72
|
required?: boolean;
|
|
72
73
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
73
74
|
multiple?: boolean;
|
|
74
75
|
help?: string;
|
|
75
76
|
alias?: string | readonly string[];
|
|
76
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts
|
|
77
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, {
|
|
78
|
+
exists?: boolean;
|
|
79
|
+
}>) => {
|
|
77
80
|
shouldStop: boolean;
|
|
78
81
|
} | void) | undefined;
|
|
79
|
-
} &
|
|
82
|
+
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
80
83
|
exists?: boolean;
|
|
81
|
-
}
|
|
82
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
83
|
-
exists?: boolean;
|
|
84
|
-
}>) => string) | undefined;
|
|
85
|
-
} & O;
|
|
84
|
+
}>> & O;
|
|
86
85
|
directory: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
87
86
|
exists?: boolean;
|
|
88
87
|
}>>>(overrides?: O | undefined) => {
|
|
@@ -92,40 +91,38 @@ export declare const Args: {
|
|
|
92
91
|
exists?: boolean;
|
|
93
92
|
}>) => string;
|
|
94
93
|
type?: import('../index.js').FlagKind;
|
|
95
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
94
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
95
|
+
exists?: boolean;
|
|
96
|
+
}>) => Promise<any>) | undefined;
|
|
96
97
|
description?: string;
|
|
97
98
|
required?: boolean;
|
|
98
99
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
99
100
|
multiple?: boolean;
|
|
100
101
|
help?: string;
|
|
101
102
|
alias?: string | readonly string[];
|
|
102
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts
|
|
103
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, {
|
|
104
|
+
exists?: boolean;
|
|
105
|
+
}>) => {
|
|
103
106
|
shouldStop: boolean;
|
|
104
107
|
} | void) | undefined;
|
|
105
|
-
} &
|
|
108
|
+
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
106
109
|
exists?: boolean;
|
|
107
|
-
}
|
|
108
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
109
|
-
exists?: boolean;
|
|
110
|
-
}>) => string) | undefined;
|
|
111
|
-
} & O;
|
|
110
|
+
}>> & O;
|
|
112
111
|
url: <const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>>>(overrides?: O | undefined) => {
|
|
113
112
|
[x: string]: unknown;
|
|
114
113
|
} & {
|
|
115
114
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => URL;
|
|
116
115
|
type?: import('../index.js').FlagKind;
|
|
117
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
116
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
118
117
|
description?: string;
|
|
119
118
|
required?: boolean;
|
|
120
119
|
default?: URL | URL[] | (() => URL | URL[] | null) | (() => Promise<URL | URL[] | null>) | null | undefined;
|
|
121
120
|
multiple?: boolean;
|
|
122
121
|
help?: string;
|
|
123
122
|
alias?: string | readonly string[];
|
|
124
|
-
handler?: ((value: URL, opts: import('../index.js').FlagOpts) => {
|
|
123
|
+
handler?: ((value: URL, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
125
124
|
shouldStop: boolean;
|
|
126
125
|
} | void) | undefined;
|
|
127
|
-
} &
|
|
128
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => URL) | undefined;
|
|
129
|
-
} & O;
|
|
126
|
+
} & Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>> & O;
|
|
130
127
|
custom: typeof custom;
|
|
131
128
|
};
|
|
@@ -5,16 +5,14 @@ export declare const booleanFlag: <const O extends Partial<import('../lib/types.
|
|
|
5
5
|
} & {
|
|
6
6
|
parse: (input: any, opts: FlagOpts<any, import('../lib/types.js').CustomOptions>) => boolean;
|
|
7
7
|
type?: import('../lib/types.js').FlagKind;
|
|
8
|
-
ask?: (opts: FlagOpts) => Promise<any
|
|
8
|
+
ask?: ((opts: FlagOpts<any, import('../lib/types.js').CustomOptions>) => Promise<any>) | undefined;
|
|
9
9
|
description?: string;
|
|
10
10
|
required?: boolean;
|
|
11
11
|
default?: boolean | boolean[] | (() => boolean | boolean[] | null) | (() => Promise<boolean | boolean[] | null>) | null | undefined;
|
|
12
12
|
multiple?: boolean;
|
|
13
13
|
help?: string;
|
|
14
14
|
alias?: string | readonly string[];
|
|
15
|
-
handler?: ((value: boolean, opts: FlagOpts) => {
|
|
15
|
+
handler?: ((value: boolean, opts: FlagOpts<any, import('../lib/types.js').CustomOptions>) => {
|
|
16
16
|
shouldStop: boolean;
|
|
17
17
|
} | void) | undefined;
|
|
18
|
-
} &
|
|
19
|
-
parse?: ((input: any, opts: FlagOpts<any, import('../lib/types.js').CustomOptions>) => boolean) | undefined;
|
|
20
|
-
} & O;
|
|
18
|
+
} & Partial<import('../lib/types.js').FlagDefinition<boolean, import('../lib/types.js').CustomOptions>> & O;
|
|
@@ -8,20 +8,20 @@ export declare const directoryFlag: <const O extends Partial<import('../index.js
|
|
|
8
8
|
exists?: boolean;
|
|
9
9
|
}>) => string;
|
|
10
10
|
type?: import('../index.js').FlagKind;
|
|
11
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
11
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
12
|
+
exists?: boolean;
|
|
13
|
+
}>) => Promise<any>) | undefined;
|
|
12
14
|
description?: string;
|
|
13
15
|
required?: boolean;
|
|
14
16
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
15
17
|
multiple?: boolean;
|
|
16
18
|
help?: string;
|
|
17
19
|
alias?: string | readonly string[];
|
|
18
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts
|
|
20
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, {
|
|
21
|
+
exists?: boolean;
|
|
22
|
+
}>) => {
|
|
19
23
|
shouldStop: boolean;
|
|
20
24
|
} | void) | undefined;
|
|
21
|
-
} &
|
|
25
|
+
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
22
26
|
exists?: boolean;
|
|
23
|
-
}
|
|
24
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
25
|
-
exists?: boolean;
|
|
26
|
-
}>) => string) | undefined;
|
|
27
|
-
} & O;
|
|
27
|
+
}>> & O;
|
package/dist/cjs/flags/file.d.ts
CHANGED
|
@@ -8,20 +8,20 @@ export declare const fileFlag: <const O extends Partial<import('../index.js').Fl
|
|
|
8
8
|
exists?: boolean;
|
|
9
9
|
}>) => string;
|
|
10
10
|
type?: import('../index.js').FlagKind;
|
|
11
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
11
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
12
|
+
exists?: boolean;
|
|
13
|
+
}>) => Promise<any>) | undefined;
|
|
12
14
|
description?: string;
|
|
13
15
|
required?: boolean;
|
|
14
16
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
15
17
|
multiple?: boolean;
|
|
16
18
|
help?: string;
|
|
17
19
|
alias?: string | readonly string[];
|
|
18
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts
|
|
20
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, {
|
|
21
|
+
exists?: boolean;
|
|
22
|
+
}>) => {
|
|
19
23
|
shouldStop: boolean;
|
|
20
24
|
} | void) | undefined;
|
|
21
|
-
} &
|
|
25
|
+
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
22
26
|
exists?: boolean;
|
|
23
|
-
}
|
|
24
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
25
|
-
exists?: boolean;
|
|
26
|
-
}>) => string) | undefined;
|
|
27
|
-
} & O;
|
|
27
|
+
}>> & O;
|
|
@@ -22,19 +22,17 @@ export declare const Flags: {
|
|
|
22
22
|
} & {
|
|
23
23
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => string;
|
|
24
24
|
type?: import('../index.js').FlagKind;
|
|
25
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
25
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
26
26
|
description?: string;
|
|
27
27
|
required?: boolean;
|
|
28
28
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
29
29
|
multiple?: boolean;
|
|
30
30
|
help?: string;
|
|
31
31
|
alias?: string | readonly string[];
|
|
32
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts) => {
|
|
32
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
33
33
|
shouldStop: boolean;
|
|
34
34
|
} | void) | undefined;
|
|
35
|
-
} &
|
|
36
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => string) | undefined;
|
|
37
|
-
} & O;
|
|
35
|
+
} & Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions>> & O;
|
|
38
36
|
number: <const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
39
37
|
min?: number;
|
|
40
38
|
max?: number;
|
|
@@ -47,43 +45,42 @@ export declare const Flags: {
|
|
|
47
45
|
max?: number;
|
|
48
46
|
}>) => number;
|
|
49
47
|
type?: import('../index.js').FlagKind;
|
|
50
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
48
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
49
|
+
min?: number;
|
|
50
|
+
max?: number;
|
|
51
|
+
}>) => Promise<any>) | undefined;
|
|
51
52
|
description?: string;
|
|
52
53
|
required?: boolean;
|
|
53
54
|
default?: number | number[] | (() => number | number[] | null) | (() => Promise<number | number[] | null>) | null | undefined;
|
|
54
55
|
multiple?: boolean;
|
|
55
56
|
help?: string;
|
|
56
57
|
alias?: string | readonly string[];
|
|
57
|
-
handler?: ((value: number, opts: import('../index.js').FlagOpts
|
|
58
|
+
handler?: ((value: number, opts: import('../index.js').FlagOpts<any, {
|
|
59
|
+
min?: number;
|
|
60
|
+
max?: number;
|
|
61
|
+
}>) => {
|
|
58
62
|
shouldStop: boolean;
|
|
59
63
|
} | void) | undefined;
|
|
60
|
-
} &
|
|
64
|
+
} & Partial<import('../index.js').FlagDefinition<number, {
|
|
61
65
|
min?: number;
|
|
62
66
|
max?: number;
|
|
63
|
-
}
|
|
64
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
65
|
-
min?: number;
|
|
66
|
-
max?: number;
|
|
67
|
-
}>) => number) | undefined;
|
|
68
|
-
} & O;
|
|
67
|
+
}>> & O;
|
|
69
68
|
boolean: <const O extends Partial<import('../index.js').FlagDefinition<boolean, import('../index.js').CustomOptions>>>(overrides?: O | undefined) => {
|
|
70
69
|
[x: string]: unknown;
|
|
71
70
|
} & {
|
|
72
71
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => boolean;
|
|
73
72
|
type?: import('../index.js').FlagKind;
|
|
74
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
73
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
75
74
|
description?: string;
|
|
76
75
|
required?: boolean;
|
|
77
76
|
default?: boolean | boolean[] | (() => boolean | boolean[] | null) | (() => Promise<boolean | boolean[] | null>) | null | undefined;
|
|
78
77
|
multiple?: boolean;
|
|
79
78
|
help?: string;
|
|
80
79
|
alias?: string | readonly string[];
|
|
81
|
-
handler?: ((value: boolean, opts: import('../index.js').FlagOpts) => {
|
|
80
|
+
handler?: ((value: boolean, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
82
81
|
shouldStop: boolean;
|
|
83
82
|
} | void) | undefined;
|
|
84
|
-
} &
|
|
85
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => boolean) | undefined;
|
|
86
|
-
} & O;
|
|
83
|
+
} & Partial<import('../index.js').FlagDefinition<boolean, import('../index.js').CustomOptions>> & O;
|
|
87
84
|
option: typeof optionFlag;
|
|
88
85
|
file: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
89
86
|
exists?: boolean;
|
|
@@ -94,23 +91,23 @@ export declare const Flags: {
|
|
|
94
91
|
exists?: boolean;
|
|
95
92
|
}>) => string;
|
|
96
93
|
type?: import('../index.js').FlagKind;
|
|
97
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
94
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
95
|
+
exists?: boolean;
|
|
96
|
+
}>) => Promise<any>) | undefined;
|
|
98
97
|
description?: string;
|
|
99
98
|
required?: boolean;
|
|
100
99
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
101
100
|
multiple?: boolean;
|
|
102
101
|
help?: string;
|
|
103
102
|
alias?: string | readonly string[];
|
|
104
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts
|
|
103
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, {
|
|
104
|
+
exists?: boolean;
|
|
105
|
+
}>) => {
|
|
105
106
|
shouldStop: boolean;
|
|
106
107
|
} | void) | undefined;
|
|
107
|
-
} &
|
|
108
|
+
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
108
109
|
exists?: boolean;
|
|
109
|
-
}
|
|
110
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
111
|
-
exists?: boolean;
|
|
112
|
-
}>) => string) | undefined;
|
|
113
|
-
} & O;
|
|
110
|
+
}>> & O;
|
|
114
111
|
directory: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
115
112
|
exists?: boolean;
|
|
116
113
|
}>>>(overrides?: O | undefined) => {
|
|
@@ -120,41 +117,39 @@ export declare const Flags: {
|
|
|
120
117
|
exists?: boolean;
|
|
121
118
|
}>) => string;
|
|
122
119
|
type?: import('../index.js').FlagKind;
|
|
123
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
120
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
121
|
+
exists?: boolean;
|
|
122
|
+
}>) => Promise<any>) | undefined;
|
|
124
123
|
description?: string;
|
|
125
124
|
required?: boolean;
|
|
126
125
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
127
126
|
multiple?: boolean;
|
|
128
127
|
help?: string;
|
|
129
128
|
alias?: string | readonly string[];
|
|
130
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts
|
|
129
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, {
|
|
130
|
+
exists?: boolean;
|
|
131
|
+
}>) => {
|
|
131
132
|
shouldStop: boolean;
|
|
132
133
|
} | void) | undefined;
|
|
133
|
-
} &
|
|
134
|
+
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
134
135
|
exists?: boolean;
|
|
135
|
-
}
|
|
136
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
137
|
-
exists?: boolean;
|
|
138
|
-
}>) => string) | undefined;
|
|
139
|
-
} & O;
|
|
136
|
+
}>> & O;
|
|
140
137
|
url: <const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>>>(overrides?: O | undefined) => {
|
|
141
138
|
[x: string]: unknown;
|
|
142
139
|
} & {
|
|
143
140
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => URL;
|
|
144
141
|
type?: import('../index.js').FlagKind;
|
|
145
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
142
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
146
143
|
description?: string;
|
|
147
144
|
required?: boolean;
|
|
148
145
|
default?: URL | URL[] | (() => URL | URL[] | null) | (() => Promise<URL | URL[] | null>) | null | undefined;
|
|
149
146
|
multiple?: boolean;
|
|
150
147
|
help?: string;
|
|
151
148
|
alias?: string | readonly string[];
|
|
152
|
-
handler?: ((value: URL, opts: import('../index.js').FlagOpts) => {
|
|
149
|
+
handler?: ((value: URL, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
153
150
|
shouldStop: boolean;
|
|
154
151
|
} | void) | undefined;
|
|
155
|
-
} &
|
|
156
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => URL) | undefined;
|
|
157
|
-
} & O;
|
|
152
|
+
} & Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>> & O;
|
|
158
153
|
custom: typeof custom;
|
|
159
154
|
};
|
|
160
155
|
export { Args } from '../args/index.js';
|
|
@@ -11,22 +11,23 @@ export declare const numberFlag: <const O extends Partial<import('../index.js').
|
|
|
11
11
|
max?: number;
|
|
12
12
|
}>) => number;
|
|
13
13
|
type?: import('../index.js').FlagKind;
|
|
14
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
14
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
15
|
+
min?: number;
|
|
16
|
+
max?: number;
|
|
17
|
+
}>) => Promise<any>) | undefined;
|
|
15
18
|
description?: string;
|
|
16
19
|
required?: boolean;
|
|
17
20
|
default?: number | number[] | (() => number | number[] | null) | (() => Promise<number | number[] | null>) | null | undefined;
|
|
18
21
|
multiple?: boolean;
|
|
19
22
|
help?: string;
|
|
20
23
|
alias?: string | readonly string[];
|
|
21
|
-
handler?: ((value: number, opts: import('../index.js').FlagOpts
|
|
24
|
+
handler?: ((value: number, opts: import('../index.js').FlagOpts<any, {
|
|
25
|
+
min?: number;
|
|
26
|
+
max?: number;
|
|
27
|
+
}>) => {
|
|
22
28
|
shouldStop: boolean;
|
|
23
29
|
} | void) | undefined;
|
|
24
|
-
} &
|
|
30
|
+
} & Partial<import('../index.js').FlagDefinition<number, {
|
|
25
31
|
min?: number;
|
|
26
32
|
max?: number;
|
|
27
|
-
}
|
|
28
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
29
|
-
min?: number;
|
|
30
|
-
max?: number;
|
|
31
|
-
}>) => number) | undefined;
|
|
32
|
-
} & O;
|
|
33
|
+
}>> & O;
|
|
@@ -4,16 +4,14 @@ export declare const stringFlag: <const O extends Partial<import('../index.js').
|
|
|
4
4
|
} & {
|
|
5
5
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => string;
|
|
6
6
|
type?: import('../index.js').FlagKind;
|
|
7
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
7
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
8
8
|
description?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
help?: string;
|
|
13
13
|
alias?: string | readonly string[];
|
|
14
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts) => {
|
|
14
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
15
15
|
shouldStop: boolean;
|
|
16
16
|
} | void) | undefined;
|
|
17
|
-
} &
|
|
18
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => string) | undefined;
|
|
19
|
-
} & O;
|
|
17
|
+
} & Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions>> & O;
|
package/dist/cjs/flags/url.d.ts
CHANGED
|
@@ -4,16 +4,14 @@ export declare const urlFlag: <const O extends Partial<import('../index.js').Fla
|
|
|
4
4
|
} & {
|
|
5
5
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => URL;
|
|
6
6
|
type?: import('../index.js').FlagKind;
|
|
7
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
7
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
8
8
|
description?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
default?: URL | URL[] | (() => URL | URL[] | null) | (() => Promise<URL | URL[] | null>) | null | undefined;
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
help?: string;
|
|
13
13
|
alias?: string | readonly string[];
|
|
14
|
-
handler?: ((value: URL, opts: import('../index.js').FlagOpts) => {
|
|
14
|
+
handler?: ((value: URL, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
15
15
|
shouldStop: boolean;
|
|
16
16
|
} | void) | undefined;
|
|
17
|
-
} &
|
|
18
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => URL) | undefined;
|
|
19
|
-
} & O;
|
|
17
|
+
} & Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>> & O;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`chalk`);l=c(l,1);let u=require(`node:fs`);u=c(u,1);let d=require(`node:path`);d=c(d,1);let f=require(`minimist`);f=c(f,1);let p=require(`@inquirer/prompts`),ee=require(`inquirer-file-selector`);var m=class{level;constructor(e={}){this.level=e.level??`info`}shouldLog(e){let t=[`debug`,`info`,`warn`,`error`],n=t.indexOf(this.level);return t.indexOf(e)>=n}setLevel(e){this.level=e}getLevel(){return this.level}log(...e){console.log(...e)}info(...e){this.shouldLog(`info`)&&console.log(...e)}warn(...e){this.shouldLog(`warn`)&&console.warn(...e)}error(...e){this.shouldLog(`error`)&&console.error(...e)}debug(...e){this.shouldLog(`debug`)&&console.log(...e)}},te=.1,ne=4,h=.5,g=class{calculateSimilarity(e,t){if(e===t)return 1;let n=e.toLowerCase(),r=t.toLowerCase();if(n===r)return 1;if(n.length===0||r.length===0)return 0;let i=this.jaro(n,r);if(i===0)return 0;let a=0,o=Math.min(ne,n.length,r.length);for(;a<o&&n[a]===r[a];)a++;let s=i+a*te*(1-i),c=Math.min(n.length,r.length)/Math.max(n.length,r.length);return s*(c<h?c/h:1)}jaro(e,t){let n=Math.max(0,Math.floor(Math.max(e.length,t.length)/2)-1),r=Array(e.length).fill(!1),i=Array(t.length).fill(!1),a=0;for(let o=0;o<e.length;o++){let s=Math.max(0,o-n),c=Math.min(o+n+1,t.length);for(let n=s;n<c;n++)if(!i[n]&&e[o]===t[n]){r[o]=!0,i[n]=!0,a++;break}}if(a===0)return 0;let o=0,s=0;for(let n=0;n<e.length;n++)if(r[n]){for(;!i[s];)s++;e[n]!==t[s]&&o++,s++}return o/=2,(a/e.length+a/t.length+(a-o)/a)/3}findBestMatch(e,t){let n=t.map(t=>({target:t,rating:this.calculateSimilarity(e,t)})),r=0,i=n[0]?.rating??0;for(let e=1;e<n.length;e++)n[e].rating>i&&(i=n[e].rating,r=e);return{ratings:n,bestMatch:n[r],bestMatchIndex:r}}},_=class extends Error{};function v(e){return l.default.bold.yellow(`'${e}'`)}var re=/\x1b\[[0-9;]*m/g;function ie(e){return e.replace(re,``).length}function y(e,t){let{title:n,details:r,hint:i}=t,a=r&&r.length>0||i!=null,o=l.default.dim(`│`),s=l.default.dim(`└─`);if(e.log(``),e.log(` ${l.default.red(`error:`)} ${n}`),a){if(e.log(` ${o}`),r&&r.length>0){let t=r.map(([e])=>ie(e)),n=Math.max(...t);for(let i=0;i<r.length;i++){let[a,s]=r[i],c=` `.repeat(n-t[i]);e.log(` ${o} ${a}${c} ${s}`)}}i==null?e.log(` ${o}`):(e.log(` ${o}`),e.log(` ${s} try: ${i}`))}e.log(``)}var ae=class extends _{$type=`CommandNotFoundError`;constructor(e){super(`Command "${e}" not found.`),this.command=e}pretty(e){y(e,{title:`command ${v(this.command)} not found`})}};function b(e,t){let n=t.multiple===!0,r=t.required?`${l.default.yellow.bold(e)} is required`:`Enter ${l.default.yellow.bold(e)}`;return t.description&&(r+=`: ${l.default.gray(`(${t.description})`)}`),r+=` ${l.default.green(`(${t.type}${n?`[]`:``})`)}\n`,r}function x(e){return e==null?[]:typeof e==`string`?[e]:e}function S(e){return e.length===1?`-${e}`:`--${e}`}function C(e){return e.type===`option`&&`options`in e}var w=class extends _{$type=`InvalidFlag`;constructor(e,t={}){super(`Flag ${e} is not recognized`),this.flag=e,this.flagsSchema=t}pretty(e){let t=Object.entries(this.flagsSchema).map(([e,t])=>{let n=x(t.alias),r=`--${e}${n.length>0?n.map(e=>`, ${S(e)}`).join(``):``}`,i=C(t)?t.options.join(` | `):t.type,a=t.description??``,o=a?`${a} ${l.default.dim(`(${i})`)}`:l.default.dim(`(${i})`);return[l.default.cyan(r),o]});y(e,{title:`flag ${v(this.flag)} is not recognized`,details:t})}},T=class extends _{$type=`MissingRequiredArgumentValue`;constructor(e){super(`Argument "${e}" is required.`),this.argument=e}pretty(e){y(e,{title:`argument ${v(this.argument)} is required`})}},E=class extends _{$type=`MissingRequiredFlagValue`;constructor(e){super(`Flag "${e}" is required.`),this.flag=e}pretty(e){y(e,{title:`flag ${v(this.flag)} is required`})}},D=class extends Error{constructor(e){super(e)}},O=class extends _{$type=`BadCommandArgument`;constructor(e,t){let n=`Argument "${e.arg}" value is invalid.`;e.reason?n+=` Reason: ${e.reason}`:n+=` Value: "${e.value}"`,super(n),this.detail=e,this.argDefinition=t}pretty(e){let t=[];this.detail.value!=null&&t.push([l.default.dim(`value`),l.default.yellow(`"${this.detail.value}"`)]),this.detail.reason!=null&&t.push([l.default.dim(`reason`),this.detail.reason]),this.argDefinition?.help!=null&&t.push([l.default.dim(`help`),l.default.green(this.argDefinition.help)]),y(e,{title:`argument ${v(this.detail.arg)} is invalid`,details:t})}},k=class extends _{$type=`BadCommandFlag`;constructor(e,t){let n=`Flag "${e.flag}" value is invalid.`;e.reason?n+=` Reason: ${e.reason}`:n+=` Value: "${e.value}"`,super(n),this.param=e,this.flagDefinition=t}pretty(e){let t=[];this.param.value!=null&&t.push([l.default.dim(`value`),l.default.yellow(`"${this.param.value}"`)]),this.param.reason!=null&&t.push([l.default.dim(`reason`),this.param.reason]),this.flagDefinition?.help!=null&&t.push([l.default.dim(`help`),l.default.green(this.flagDefinition.help)]),y(e,{title:`flag ${v(this.param.flag)} is invalid`,details:t})}},oe=class extends _{$type=`TooManyArguments`;constructor(e,t){super(`Too many arguments provided. Expected ${e}, got ${t}.`),this.expected=e,this.received=t}pretty(e){y(e,{title:`too many arguments`,details:[[l.default.dim(`expected`),l.default.green(String(this.expected))],[l.default.dim(`received`),l.default.bold.yellow(String(this.received))]]})}},se=class{flags;parsedFlags=null;args;parsedArgs=null;ux;shouldPromptForMissingFlags=!0;shouldValidateUnknownFlags=!0;shouldRejectExtraArguments=!1;constructor(e){this.opts=e,this.ux=e.ux,this.flags=e.flags,this.args=e.args}async init(e){let{_:t,...n}=(0,f.default)(e);return this.shouldValidateUnknownFlags&&this.validateUnknownFlags(n),this.parsedFlags=await this.handleOptions(n),this.parsedArgs=await this.handleArguments(t),{flags:this.parsedFlags,args:this.parsedArgs}}async validate(){await this.validateSchema(this.flags,this.parsedFlags,`flag`),await this.validateSchema(this.args,this.parsedArgs,`arg`)}flag(e,t){if(!this.parsedFlags)throw Error(`Flags have not been parsed yet. Call init() first.`);return this.isEmptyValue(this.parsedFlags[e])&&t!==void 0?t:this.parsedFlags[e]}async setFlag(e,t){if(!this.parsedFlags)throw Error(`Flags have not been parsed yet. Call init() first.`);if(!(e in this.flags))throw new w(e,this.flags);this.parsedFlags[e]=t}argument(e,t){if(!this.parsedArgs)throw Error(`Arguments have not been parsed yet. Call init() first.`);return this.isEmptyValue(this.parsedArgs[e])&&t!==void 0?t:this.parsedArgs[e]}async setArgument(e,t){if(!this.parsedArgs)throw Error(`Arguments have not been parsed yet. Call init() first.`);if(!(e in this.args))throw new O({arg:e,reason:`Argument "${e}" is not recognized`});this.parsedArgs[e]=t}isEmptyValue(e){return e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0}isMissing(e){return e==null||Array.isArray(e)&&e.length===0}validateUnknownFlags(e){let t=new Set;for(let e in this.flags){t.add(e);let n=this.flags[e],r=Array.isArray(n.alias)?n.alias:n.alias?[n.alias]:[];for(let e of r)t.add(e)}for(let n in e)if(!t.has(n))throw new w(n,this.flags)}async handleOptions(e){let t={};for(let n in this.flags)t[n]=await this.resolveFlagValue(n,this.flags[n],e);return t}async handleArguments(e){let t={},n=[...e],r=Object.keys(this.args).length;for(let e in this.args){let r=this.args[e];if(r.multiple){t[e]=await this.parseValue(n,r,`arg`,{name:e}),n.length=0;continue}t[e]=await this.parseValue(n.shift(),r,`arg`,{name:e})}if(this.shouldRejectExtraArguments&&n.length>0)throw new oe(r,r+n.length);return t}async resolveFlagValue(e,t,n){let r,i=[e];t.alias&&i.push(...Array.isArray(t.alias)?t.alias:[t.alias]);for(let e of i)if(e in n){r=n[e];break}return this.parseValue(r,t,`flag`,{name:e})}async parseValue(e,t,n,r){if(this.isMissing(e))return typeof t.default==`function`?await t.default():t.default;if(t.multiple){Array.isArray(e)||(e=[e]);let i=[];for(let a of e)i.push(await this.safeParse(a,t,n,r));return i}return this.safeParse(e,t,n,r)}buildOpts(e,t){return{name:e,ux:this.ux,ctx:this.opts.ctx,definition:t,cmd:this.opts.cmd??Q}}async safeParse(e,t,n,r){try{return t.parse(e,this.buildOpts(r?.name??``,t))}catch(t){if(t instanceof k||t instanceof O||!(t instanceof D)||!r)throw t;let i=t.message;throw n===`flag`?new k({flag:r.name,value:e,reason:i}):new O({arg:r.name,value:e,reason:i})}}async validateSchema(e,t,n){for(let r in e){let i=e[r],a=t?.[r],o=this.isEmptyValue(a);if(i.required&&o){if(!this.shouldPromptForMissingFlags)throw n===`flag`?new E(r):new T(r);let e=await this.promptFor(r,i);if(e!=null&&t)a=await this.parseValue(e,i,n,{name:r}),t[r]=a;else throw n===`flag`?new E(r):new T(r)}}}disablePrompting(){return this.shouldPromptForMissingFlags=!1,this}allowUnknownFlags(){return this.shouldValidateUnknownFlags=!1,this}strictMode(){return this.shouldRejectExtraArguments=!0,this}async promptFor(e,t){return t.ask?t.ask(this.buildOpts(e,t)):null}};function A(e={}){return function(t){return{type:`custom`,default:e.multiple||t?.multiple?[]:null,parse:e=>e,...e,...t}}}function ce(e){if(typeof e==`boolean`)throw new D(`Expected a string, got boolean "${e}"`);return String(e)}function le(e,t){let n=typeof e==`number`?e:Number(e);if(isNaN(n))throw new D(`must be a valid number`);if(t?.min!==void 0&&n<t.min)throw new D(`is below minimum ${t.min}`);if(t?.max!==void 0&&n>t.max)throw new D(`exceeds maximum ${t.max}`);return n}function ue(e){if(typeof e==`boolean`)return e;let t=String(e).toLowerCase();if(t===`true`||t===`1`)return!0;if(t===`false`||t===`0`)return!1;throw new D(`Invalid boolean value: "${e}". Expected true, false, 1, or 0.`)}function de(e,t){let n=String(e);if(!t.includes(n))throw new D(`must be one of: ${t.map(e=>`"${e}"`).join(`, `)}`);return n}function fe(e,t){let n=String(e);if(t?.exists)try{u.default.accessSync(n,u.default.constants.F_OK)}catch(e){let t=e.code;throw t===`ENOENT`?new D(`file does not exist`):t===`EACCES`?new D(`file is not accessible (permission denied)`):new D(`file is not accessible (${t??e.message})`)}return n}function pe(e,t){let n=String(e);if(t?.exists){let e;try{e=u.default.lstatSync(n)}catch(e){let t=e.code;throw t===`ENOENT`?new D(`directory does not exist`):t===`EACCES`?new D(`directory is not accessible (permission denied)`):t===`ELOOP`?new D(`symlink loop detected`):new D(`directory is not accessible (${t??e.message})`)}if(!e.isDirectory())throw new D(`path is not a directory`)}return n}function me(e){try{return new URL(String(e))}catch(t){throw new D(`Invalid URL "${e}": ${t instanceof Error?t.message:String(t)}`)}}var he=A({default:!1,parse:e=>ue(e),ask:async e=>{let t=b(e.name,e.definition);return await e.ux.askForToggle(t)},type:`boolean`});function j(e,t){return n=>{if((n==null||typeof n==`string`&&n.trim()===``)&&e.required)return`This value is required`;try{e.parse(n,t)}catch(e){if(e instanceof D)return e.message;throw e}return!0}}function M(e,t){return n=>{if((n==null||n.trim()===``)&&e.required)return`Please enter at least one value`;for(let r of n.split(`,`)){let n=r.trim();if(n!==``)try{e.parse(n,t)}catch(e){if(e instanceof D)return`"${n}": ${e.message}`;throw e}}return!0}}async function ge(e){let t=e.definition,n=t.multiple===!0,r=b(e.name,t);return n?await e.ux.askForList(r+`Please provide one or more values, separated by commas:
|
|
2
2
|
`,{separator:`,`,validate:M(t,e)}):t.secret?e.ux.askForPassword(r,{validate:j(t,e)}):await e.ux.askForInput(r,{validate:j(t,e)})}async function _e(e){let t=e.definition,n=t.multiple===!0,r=b(e.name,t);return n?await e.ux.askForList(r+`Please provide one or more values, separated by commas:
|
|
3
3
|
`,{separator:`,`,validate:M(t,e)}):await e.ux.askForNumber(r,{validate:n=>{if(n===void 0&&t.required)return`This value is required`;if(n!==void 0)try{t.parse(String(n),e)}catch(e){if(e instanceof D)return e.message;throw e}return!0}})}async function ve(e){let t=e.definition,n=t.multiple===!0,r=b(e.name,t);if(!C(t))return null;let i=t.options.map(e=>({name:e,value:e}));return n?await e.ux.askForCheckbox(r,i):await e.ux.askForSelect(r,i)}async function ye(e){let t=b(e.name,e.definition);return e.ux.askForFile(t,{basePath:process.cwd()})}async function be(e){let t=b(e.name,e.definition);return e.ux.askForDirectory(t,{basePath:process.cwd()})}async function xe(e){let t=b(e.name,e.definition);return await e.ux.askForInput(t,{validate:j(e.definition,e)})}var N=A({parse:(e,t)=>pe(e,{exists:t.definition.exists}),ask:be,type:`directory`}),P=A({parse:(e,t)=>fe(e,{exists:t.definition.exists}),ask:ye,type:`file`}),F=A({parse:(e,t)=>le(e,{min:t.definition.min,max:t.definition.max}),ask:_e,type:`number`});function I(e){let{options:t,...n}=e;return A({type:`option`,ask:ve,parse:e=>de(e,t??[]),...e})(n)}var L=A({parse:e=>ce(e),ask:ge,type:`string`}),R=A({parse:e=>me(e),ask:xe,type:`url`}),z={string:L,number:F,option:I,file:P,directory:N,url:R,custom:A},B={string:L,number:F,boolean:he,option:I,file:P,directory:N,url:R,custom:A};function V(e){return Array(e+5).join(` `)}function Se(e){let t=e.type;return C(e)?`enum: ${e.options.join(`|`)}`:t??`custom`}var Ce=B.boolean({alias:[`h`],description:`Displays help information about the command`,handler:(e,t)=>{if(!e)return{shouldStop:!1};let n=t.cmd,r=n.args,i={...n.baseFlags,...n.flags},a=Object.entries(r),o=Object.entries(i),s=o.map(([e,t])=>{let n=x(t.alias);return{name:e,...t,flagWithAlias:`--${e}${n.map(e=>`, ${S(e)}`).join(``)}`}}),c=a.filter(([,e])=>e.required);console.log(l.default.yellow(`Description:`)),console.log(` ${n.description}\n`),n.aliases.length>0&&(console.log(l.default.yellow(`Aliases:`)),console.log(` ${n.aliases.join(`, `)}\n`)),console.log(l.default.yellow(`Usage:`)),console.log(` ${n.command} ${c.length>0?c.map(([e])=>`<${e}>`).join(` `):`\b`} [options]`);let u=Math.max(...s.map(e=>e.flagWithAlias.length),0),d=Math.max(...a.map(([e])=>e.length),0),f=d>u?d:u;if(a.length>0){console.log(`\n${l.default.yellow(`Arguments`)}:`);for(let[e,t]of a){let n=V(f-e.length),r=` ${l.default.green(e)} ${n} ${t.description??`\b`}`;if(t.default!==void 0&&!t.required){let e=typeof t.default==`function`?`[function]`:t.multiple?JSON.stringify(t.default):t.default;r+=` ${l.default.yellow(`[default: ${e}]`)}`}t.multiple&&(r+=` ${l.default.white(`(multiple)`)}`),console.log(r)}}if(o.length>0){console.log(`\n${l.default.yellow(`Options`)}:`);for(let e of s){let t=V(f-e.flagWithAlias.length),n=` ${l.default.green(e.flagWithAlias)} ${t} ${e.description??`\b`}`;if(e.type&&(n+=` ${l.default.white(`(${Se(e)})`)}`),e.default!==void 0&&!e.required){let t=typeof e.default==`function`?`(function)`:e.default;n+=` ${l.default.yellow(`[default: ${t}]`)}`}console.log(n)}}let p=n.examples??[];if(p.length>0){console.log(`\n${l.default.yellow(`Examples`)}:`);let e=process.argv[0].split(`/`).pop();e===`node`&&(e+=` `+process.argv[1].split(`/`).pop());for(let[t,n]of p.entries())t>0&&console.log(``),console.log(` ${n.description}\n`),console.log(` ${l.default.green(`${e} ${n.command}`)}`)}return{shouldStop:!0}}}),we=class extends Error{name=`ExitPromptError`},Te=o(((e,t)=>{t.exports={}}));async function H(e,t){try{return await e()}catch(e){if(e instanceof we||e instanceof Error&&e.name===`ExitPromptError`)return t;throw e}}async function U(e,t,n){if(t.length===0)throw Error(`No options provided`);let r=t.map(e=>typeof e==`string`?{name:e,value:e}:{name:e.name,value:e.value,disabled:e.disabled,checked:e.checked,description:e.description});return H(()=>(0,p.checkbox)({message:e,choices:r,required:n?.required,pageSize:n?.pageSize,loop:n?.loop,validate:n?.validate,shortcuts:n?.shortcuts}),null)}async function W(e=`Do you want to continue?`,t){return H(()=>(0,p.confirm)({message:e,default:t?.default??!1,transformer:t?.transformer}),null)}async function G(e,t){return H(()=>(0,p.editor)({message:e,default:t?.default,postfix:t?.postfix,waitForUserInput:t?.waitForUserInput,validate:t?.validate}),null)}async function K(e,t,n){return H(()=>(0,p.expand)({message:e,choices:t,default:n?.default}),null)}async function q(e,t){return H(async()=>{let n=await(0,ee.fileSelector)({message:e,basePath:t?.basePath,type:t?.type===`file+directory`?void 0:t?.type,filter:t?.filter,allowCancel:!0,pageSize:t?.pageSize,loop:t?.loop});return n===null?null:n.path},null)}async function J(e,t){return H(()=>(0,p.input)({message:e,default:t?.default,required:t?.required,validate:t?.validate,transformer:t?.transformer}),null)}async function Y(e,t){let n=t?.separator??`,`;return H(async()=>(await(0,p.input)({message:e,default:t?.default,validate:t?.validate})).split(n).map(e=>e.trim()).filter(e=>e.length>0),null)}async function X(e,t){return H(async()=>await(0,p.number)({message:e,default:t?.default,required:t?.required,min:t?.min,max:t?.max,step:t?.step,validate:t?.validate})??null,null)}async function Ee(e,t){return H(()=>(0,p.password)({message:e,mask:t?.mask,validate:t?.validate}),null)}async function De(e,t,n){return H(()=>(0,p.rawlist)({message:e,choices:t,loop:n?.loop}),null)}async function Oe(e,t,n){return H(()=>(0,p.search)({message:e,source:t,pageSize:n?.pageSize,validate:n?.validate}),null)}async function ke(e,t,n){if(t.length===0)throw Error(`No options provided`);let r=t.map(e=>typeof e==`string`?{name:e,value:e}:e);return H(()=>(0,p.select)({message:e,choices:r,default:n?.default,pageSize:n?.pageSize,loop:n?.loop}),null)}async function Ae(e,t){let n=t?.active??`Yes`,r=t?.inactive??`No`;return H(()=>(0,p.confirm)({message:e,default:t?.default??!1,transformer:e=>e?n:r}),null)}function je(e,t){let n=t?.separator??`: `,r=t?.keyStyle??l.default.bold,i=Array.isArray(e)?e:Object.entries(e);if(i.length===0)return;let a=Math.max(...i.map(([e])=>e.length));for(let[e,t]of i)console.log(r(e.padEnd(a))+n+String(t??``))}function Me(e=``,t=[`⠙`,`⠘`,`⠰`,`⠴`,`⠤`,`⠦`,`⠆`,`⠃`,`⠋`,`⠉`],n=100){let r=e,i=null,a=e.length,o=0,s=e=>{let t=process.stdout.columns||80,n=e+2,r=Math.max(1,Math.ceil(n/t));if(process.stdout.isTTY&&process.stdout.clearLine&&process.stdout.moveCursor&&process.stdout.cursorTo){r>1&&process.stdout.moveCursor(0,-(r-1));for(let e=0;e<r;e++)process.stdout.cursorTo(0),process.stdout.clearLine(1),e<r-1&&process.stdout.moveCursor(0,1);r>1&&process.stdout.moveCursor(0,-(r-1)),process.stdout.cursorTo(0)}else process.stdout.write(`\r`+` `.repeat(e+5)+`\r`)},c=setInterval(function(){i!==null&&(s(Math.max(i.length,r.length)),i=null),process.stdout.write(`\r`+t[o++]+` `+r),o%=t.length},n),l=()=>{clearInterval(c),s(a)};return{[Symbol.dispose]:l,[Symbol.asyncDispose]:l,updateText:e=>{i=r,r=e,a=Math.max(a,e.length)},stop:l}}function Ne(e,t){let n=t?.width??30,r=t?.completeChar??`█`,i=t?.incompleteChar??`░`,a=0,o=!1,s=()=>{if(o)return;let t=e<=0?1:Math.min(a/e,1),s=Math.round(t*n),l=`${r.repeat(s)+i.repeat(n-s)} ${Math.round(t*100)}% ${a}/${e}`;process.stdout.write(`\r`+l),(e<=0||a>=e)&&c()},c=()=>{o||(o=!0,process.stdout.write(`
|
|
4
|
-
`))};return s(),{increment:(t=1)=>{o||(a=Math.min(a+t,e),s())},update:t=>{o||(a=Math.max(0,Math.min(t,e)),s())},stop:c,[Symbol.dispose]:c,[Symbol.asyncDispose]:c}}function Pe(e,t){if(e.length===0)return;let n=t??Object.keys(e[0]).map(e=>({key:e})),r=n.map(e=>e.header??e.key.toUpperCase()),i=n.map((t,n)=>{let i=Math.max(r[n].length,...e.map(e=>(t.format?t.format(e[t.key]):String(e[t.key]??``)).length));return t.width?Math.min(i,t.width):i}),a=(e,t,n=`left`)=>{if(e.length>t)return e.slice(0,t-1)+`…`;switch(n){case`right`:return e.padStart(t);case`center`:{let n=Math.floor((t-e.length)/2);return` `.repeat(n)+e+` `.repeat(t-e.length-n)}default:return e.padEnd(t)}},o=n.map((e,t)=>a(r[t],i[t],e.alignment)).join(` `);console.log(l.default.bold(o));let s=i.map(e=>`-`.repeat(e)).join(` `);console.log(l.default.dim(s));for(let t of e){let e=n.map((e,n)=>a(e.format?e.format(t[e.key]):String(t[e.key]??``),i[n],e.alignment)).join(` `);console.log(e)}}var Z=class{askForConfirmation(e,t){return W(e,t)}askForInput(e,t){return J(e,t)}askForPassword(e,t){return Ee(e,t)}askForNumber(e,t){return X(e,t)}askForSelect(e,t,n){return ke(e,t,n)}askForCheckbox(e,t,n){return U(e,t,n)}askForSearch(e,t,n){return Oe(e,t,n)}askForList(e,t){return Y(e,t)}askForToggle(e,t){return Ae(e,t)}askForEditor(e,t){return G(e,t)}askForRawList(e,t,n){return De(e,t,n)}askForExpand(e,t,n){return K(e,t,n)}askForFile(e,t){return q(e,{...t,type:`file`})}askForDirectory(e,t){return q(e,{...t,type:`directory`})}askForFileSelector(e,t){return q(e,t)}keyValue(e,t){return je(e,t)}table(e,t){return Pe(e,t)}newProgressBar(e,t){return Ne(e,t)}newLoader(e,t,n){return Me(e,t,n)}},Q=class{static $type=`BobCommand`;static command=``;static description=``;static group;static args={};static flags={};static examples=[];static hidden=!1;static aliases=[];static disableDefaultOptions=!1;static disablePrompting=!1;static allowUnknownFlags=!1;static strictMode=!1;ctx;logger;ux;parser;static baseFlags={help:Ce};newCommandParser(e){return new se({ux:e.ux,ctx:e.ctx,flags:e.flags,args:e.args,cmd:e.cmd})}newUX(){return new Z}async run(e){let t=this.constructor;this.ctx=e.ctx,this.logger=e.logger,this.ux=this.newUX();let n;if(`flags`in e)n={flags:e.flags,args:e.args};else{this.parser=this.newCommandParser({ctx:this.ctx,ux:this.ux,flags:t.disableDefaultOptions?t.flags:{...t.baseFlags,...t.flags},args:t.args,cmd:t}),t.allowUnknownFlags&&this.parser.allowUnknownFlags(),t.strictMode&&this.parser.strictMode(),t.disablePrompting&&this.parser.disablePrompting();let r=await this.parser.init(e.args);for(let n in r.flags){let i=r.flags[n],a=t.flags[n]||t.baseFlags[n];if(a&&a.handler){let r={name:n,ux:this.ux,ctx:e.ctx,definition:a,cmd:t},o=a.handler(i,r);if(o&&o.shouldStop)return 0}}await this.parser.validate(),n={flags:r.flags,args:r.args}}if(this.preHandle){let e=await this.preHandle();if(e&&e!==0)return e}return await this.handle(this.ctx,n)??0}};function Fe(e){return e instanceof _}function $(e){return typeof e==`function`?e.prototype instanceof Q||e.$type===`BobCommand`:!1}var Ie=.75,Le=.55,Re=.05,ze=class{commands={};aliases={};ux;logger;stringSimilarity;constructor(e){this.logger=e?.logger??new m,this.ux=e?.ux??new Z,this.stringSimilarity=e?.stringSimilarity??new g}getAvailableCommands(){return[...Object.keys(this.commands),...Object.keys(this.aliases)]}getCommands(){return Object.values(this.commands)}importFile=async e=>(await import(e)).default;commandResolver=async e=>{let t=await this.importFile(e);return t?(t&&typeof t==`object`&&`default`in t&&(t=t.default),typeof t==`function`&&$(t)?t:null):null};withCommandResolver(e){return this.commandResolver=e,this}withFileImporter(e){return this.importFile=e,this}registerCommand(e,t=!1){if(!$(e))throw Error(`Invalid command, it must extend the Command class.`);let n=e.command;if(!n)throw Error(`Cannot register a command with no name. ${e.name} `);if(!t&&this.commands[n])throw Error(`Command ${n} already registered.`);if(!t&&this.aliases[n])throw Error(`Command name ${n} conflicts with an existing alias.`);this.commands[n]=e;for(let r of e.aliases){if(!t&&this.commands[r])throw Error(`Alias ${r} conflicts with an existing command name.`);if(!t&&this.aliases[r])throw Error(`Alias ${r} already registered.`);this.aliases[r]=n}}async loadCommandsPath(e){for await(let t of this.listCommandsFiles(e))try{let e=await this.commandResolver(t);$(e)&&this.registerCommand(e)}catch(e){throw Error(`Command ${t} failed to load. ${e}`,{cause:e})}}async runCommand(e,t,...n){let r;if(typeof t==`string`){let i=this.commands[t]??this.commands[this.aliases[t]];if(!i){let r=await this.suggestCommand(t);if(r)return await this.runCommand(e,r,...n);throw new ae(t)}r=new i}else r=$(t)?new t:t;return await r.run({ctx:e,logger:this.logger,args:n})??0}async suggestCommand(e){let t=this.getAvailableCommands();if(t.length===0)return null;let{bestMatch:n,bestMatchIndex:r,ratings:i}=this.stringSimilarity.findBestMatch(e,t),a=[...i].sort((e,t)=>t.rating-e.rating),o=a[1]?.rating??0,s=a.filter(e=>e.rating>=Le).map(e=>e.target);if(n&&n.rating>=Ie&&n.rating-o>Re){let n=t[r],i=await this.askRunSimilarCommand(e,n);return i===!0?n:(i===null&&this.logger.debug(`suggestion prompt cancelled for "${e}"`),null)}if(s.length===1){let t=s[0],n=await this.askRunSimilarCommand(e,t);return n===!0?t:(n===null&&this.logger.debug(`suggestion prompt cancelled for "${e}"`),null)}if(s.length>1){let t=await this.ux.askForSelect(`${l.default.red(`unknown command`)} ${l.default.bold.yellow(`'${e}'`)} ${l.default.dim(`—`)} did you mean one of these?`,s);return t||(t===null&&this.logger.debug(`suggestion selection cancelled for "${e}"`),null)}return null}async askRunSimilarCommand(e,t){return this.ux.askForConfirmation(`${l.default.red(`unknown command`)} ${l.default.bold.yellow(`'${e}'`)} ${l.default.dim(`—`)} did you mean ${l.default.bold.green(`'${t}'`)}?`)}async*listCommandsFiles(e){let t;try{t=await u.default.promises.readdir(e,{withFileTypes:!0})}catch(t){throw Error(`Failed to read commands directory "${e}": ${t.message}`,{cause:t})}for(let n of t){let t=d.default.resolve(e,n.name);if(n.isDirectory())yield*this.listCommandsFiles(d.default.resolve(e,n.name));else{if(!t.endsWith(`.ts`)&&!t.endsWith(`.js`)&&!t.endsWith(`.mjs`)&&!t.endsWith(`.cjs`))continue;yield t}}}},Be=class{logger;constructor(e){this.logger=e}handle(e){if(Fe(e))return e.pretty(this.logger),-1;throw e}},Ve=c(Te(),1);function He(){try{let e=(0,u.readFileSync)((0,Ve.fileURLToPath)(new URL(`data:application/json;base64,
|
|
4
|
+
`))};return s(),{increment:(t=1)=>{o||(a=Math.min(a+t,e),s())},update:t=>{o||(a=Math.max(0,Math.min(t,e)),s())},stop:c,[Symbol.dispose]:c,[Symbol.asyncDispose]:c}}function Pe(e,t){if(e.length===0)return;let n=t??Object.keys(e[0]).map(e=>({key:e})),r=n.map(e=>e.header??e.key.toUpperCase()),i=n.map((t,n)=>{let i=Math.max(r[n].length,...e.map(e=>(t.format?t.format(e[t.key]):String(e[t.key]??``)).length));return t.width?Math.min(i,t.width):i}),a=(e,t,n=`left`)=>{if(e.length>t)return e.slice(0,t-1)+`…`;switch(n){case`right`:return e.padStart(t);case`center`:{let n=Math.floor((t-e.length)/2);return` `.repeat(n)+e+` `.repeat(t-e.length-n)}default:return e.padEnd(t)}},o=n.map((e,t)=>a(r[t],i[t],e.alignment)).join(` `);console.log(l.default.bold(o));let s=i.map(e=>`-`.repeat(e)).join(` `);console.log(l.default.dim(s));for(let t of e){let e=n.map((e,n)=>a(e.format?e.format(t[e.key]):String(t[e.key]??``),i[n],e.alignment)).join(` `);console.log(e)}}var Z=class{askForConfirmation(e,t){return W(e,t)}askForInput(e,t){return J(e,t)}askForPassword(e,t){return Ee(e,t)}askForNumber(e,t){return X(e,t)}askForSelect(e,t,n){return ke(e,t,n)}askForCheckbox(e,t,n){return U(e,t,n)}askForSearch(e,t,n){return Oe(e,t,n)}askForList(e,t){return Y(e,t)}askForToggle(e,t){return Ae(e,t)}askForEditor(e,t){return G(e,t)}askForRawList(e,t,n){return De(e,t,n)}askForExpand(e,t,n){return K(e,t,n)}askForFile(e,t){return q(e,{...t,type:`file`})}askForDirectory(e,t){return q(e,{...t,type:`directory`})}askForFileSelector(e,t){return q(e,t)}keyValue(e,t){return je(e,t)}table(e,t){return Pe(e,t)}newProgressBar(e,t){return Ne(e,t)}newLoader(e,t,n){return Me(e,t,n)}},Q=class{static $type=`BobCommand`;static command=``;static description=``;static group;static args={};static flags={};static examples=[];static hidden=!1;static aliases=[];static disableDefaultOptions=!1;static disablePrompting=!1;static allowUnknownFlags=!1;static strictMode=!1;ctx;logger;ux;parser;static baseFlags={help:Ce};newCommandParser(e){return new se({ux:e.ux,ctx:e.ctx,flags:e.flags,args:e.args,cmd:e.cmd})}newUX(){return new Z}async run(e){let t=this.constructor;this.ctx=e.ctx,this.logger=e.logger,this.ux=this.newUX();let n;if(`flags`in e)n={flags:e.flags,args:e.args};else{this.parser=this.newCommandParser({ctx:this.ctx,ux:this.ux,flags:t.disableDefaultOptions?t.flags:{...t.baseFlags,...t.flags},args:t.args,cmd:t}),t.allowUnknownFlags&&this.parser.allowUnknownFlags(),t.strictMode&&this.parser.strictMode(),t.disablePrompting&&this.parser.disablePrompting();let r=await this.parser.init(e.args);for(let n in r.flags){let i=r.flags[n],a=t.flags[n]||t.baseFlags[n];if(a&&a.handler){let r={name:n,ux:this.ux,ctx:e.ctx,definition:a,cmd:t},o=a.handler(i,r);if(o&&o.shouldStop)return 0}}await this.parser.validate(),n={flags:r.flags,args:r.args}}if(this.preHandle){let e=await this.preHandle();if(e&&e!==0)return e}return await this.handle(this.ctx,n)??0}};function Fe(e){return e instanceof _}function $(e){return typeof e==`function`?e.prototype instanceof Q||e.$type===`BobCommand`:!1}var Ie=.75,Le=.55,Re=.05,ze=class{commands={};aliases={};ux;logger;stringSimilarity;constructor(e){this.logger=e?.logger??new m,this.ux=e?.ux??new Z,this.stringSimilarity=e?.stringSimilarity??new g}getAvailableCommands(){return[...Object.keys(this.commands),...Object.keys(this.aliases)]}getCommands(){return Object.values(this.commands)}importFile=async e=>(await import(e)).default;commandResolver=async e=>{let t=await this.importFile(e);return t?(t&&typeof t==`object`&&`default`in t&&(t=t.default),typeof t==`function`&&$(t)?t:null):null};withCommandResolver(e){return this.commandResolver=e,this}withFileImporter(e){return this.importFile=e,this}registerCommand(e,t=!1){if(!$(e))throw Error(`Invalid command, it must extend the Command class.`);let n=e.command;if(!n)throw Error(`Cannot register a command with no name. ${e.name} `);if(!t&&this.commands[n])throw Error(`Command ${n} already registered.`);if(!t&&this.aliases[n])throw Error(`Command name ${n} conflicts with an existing alias.`);this.commands[n]=e;for(let r of e.aliases){if(!t&&this.commands[r])throw Error(`Alias ${r} conflicts with an existing command name.`);if(!t&&this.aliases[r])throw Error(`Alias ${r} already registered.`);this.aliases[r]=n}}async loadCommandsPath(e){for await(let t of this.listCommandsFiles(e))try{let e=await this.commandResolver(t);$(e)&&this.registerCommand(e)}catch(e){throw Error(`Command ${t} failed to load. ${e}`,{cause:e})}}async runCommand(e,t,...n){let r;if(typeof t==`string`){let i=this.commands[t]??this.commands[this.aliases[t]];if(!i){let r=await this.suggestCommand(t);if(r)return await this.runCommand(e,r,...n);throw new ae(t)}r=new i}else r=$(t)?new t:t;return await r.run({ctx:e,logger:this.logger,args:n})??0}async suggestCommand(e){let t=this.getAvailableCommands();if(t.length===0)return null;let{bestMatch:n,bestMatchIndex:r,ratings:i}=this.stringSimilarity.findBestMatch(e,t),a=[...i].sort((e,t)=>t.rating-e.rating),o=a[1]?.rating??0,s=a.filter(e=>e.rating>=Le).map(e=>e.target);if(n&&n.rating>=Ie&&n.rating-o>Re){let n=t[r],i=await this.askRunSimilarCommand(e,n);return i===!0?n:(i===null&&this.logger.debug(`suggestion prompt cancelled for "${e}"`),null)}if(s.length===1){let t=s[0],n=await this.askRunSimilarCommand(e,t);return n===!0?t:(n===null&&this.logger.debug(`suggestion prompt cancelled for "${e}"`),null)}if(s.length>1){let t=await this.ux.askForSelect(`${l.default.red(`unknown command`)} ${l.default.bold.yellow(`'${e}'`)} ${l.default.dim(`—`)} did you mean one of these?`,s);return t||(t===null&&this.logger.debug(`suggestion selection cancelled for "${e}"`),null)}return null}async askRunSimilarCommand(e,t){return this.ux.askForConfirmation(`${l.default.red(`unknown command`)} ${l.default.bold.yellow(`'${e}'`)} ${l.default.dim(`—`)} did you mean ${l.default.bold.green(`'${t}'`)}?`)}async*listCommandsFiles(e){let t;try{t=await u.default.promises.readdir(e,{withFileTypes:!0})}catch(t){throw Error(`Failed to read commands directory "${e}": ${t.message}`,{cause:t})}for(let n of t){let t=d.default.resolve(e,n.name);if(n.isDirectory())yield*this.listCommandsFiles(d.default.resolve(e,n.name));else{if(!t.endsWith(`.ts`)&&!t.endsWith(`.js`)&&!t.endsWith(`.mjs`)&&!t.endsWith(`.cjs`))continue;yield t}}}},Be=class{logger;constructor(e){this.logger=e}handle(e){if(Fe(e))return e.pretty(this.logger),-1;throw e}},Ve=c(Te(),1);function He(){try{let e=(0,u.readFileSync)((0,Ve.fileURLToPath)(new URL(`data:application/json;base64,ewogICJuYW1lIjogImJvYi1jb3JlIiwKICAidmVyc2lvbiI6ICIzLjAuMC1iZXRhLjkiLAogICJkZXNjcmlwdGlvbiI6ICJCT0IgQ29yZSIsCiAgInR5cGUiOiAibW9kdWxlIiwKICAibWFpbiI6ICIuL2Rpc3QvY2pzL2luZGV4LmpzIiwKICAibW9kdWxlIjogIi4vZGlzdC9lc20vaW5kZXguanMiLAogICJ0eXBlcyI6ICIuL2Rpc3QvZXNtL2luZGV4LmQudHMiLAogICJmaWxlcyI6IFsKICAgICJkaXN0IgogIF0sCiAgImV4cG9ydHMiOiB7CiAgICAiLiI6IHsKICAgICAgImltcG9ydCI6IHsKICAgICAgICAidHlwZXMiOiAiLi9kaXN0L2VzbS9pbmRleC5kLnRzIiwKICAgICAgICAiZGVmYXVsdCI6ICIuL2Rpc3QvZXNtL2luZGV4LmpzIgogICAgICB9LAogICAgICAicmVxdWlyZSI6IHsKICAgICAgICAidHlwZXMiOiAiLi9kaXN0L2Nqcy9pbmRleC5kLnRzIiwKICAgICAgICAiZGVmYXVsdCI6ICIuL2Rpc3QvY2pzL2luZGV4LmpzIgogICAgICB9CiAgICB9CiAgfSwKICAic2NyaXB0cyI6IHsKICAgICJzdGFydCI6ICJub2RlIC1yIEBzd2Mtbm9kZS9yZWdpc3RlciBkZWJ1Zy9tYWluLnRzIiwKICAgICJidWlsZCI6ICJybSAtcmYgLi9kaXN0ICYmIHZpdGUgYnVpbGQiLAogICAgInR5cGVjaGVjayI6ICJ0c2MgLS1ub0VtaXQiLAogICAgInByZXBhY2siOiAibnBtIHJ1biBidWlsZCIsCiAgICAidGVzdCI6ICJ2aXRlc3QgcnVuIiwKICAgICJsaW50IjogImVzbGludCAuIiwKICAgICJsaW50OmZpeCI6ICJlc2xpbnQgLiAtLWZpeCIKICB9LAogICJhdXRob3IiOiAiTMOpbyBIdWJlcnQiLAogICJsaWNlbnNlIjogIklTQyIsCiAgImRldkRlcGVuZGVuY2llcyI6IHsKICAgICJAZXNsaW50L2pzIjogIl45LjM5LjQiLAogICAgIkBmYWtlci1qcy9mYWtlciI6ICJeMTAuMy4wIiwKICAgICJAc3djLW5vZGUvcmVnaXN0ZXIiOiAiXjEuMTEuMSIsCiAgICAiQHRyaXZhZ28vcHJldHRpZXItcGx1Z2luLXNvcnQtaW1wb3J0cyI6ICJeNS4yLjIiLAogICAgIkB0eXBlcy9taW5pbWlzdCI6ICJeMS4yLjUiLAogICAgIkB0eXBlcy9ub2RlIjogIl4yMC4xNC41IiwKICAgICJAdHlwZXMvc3RyaW5nLXNpbWlsYXJpdHkiOiAiXjQuMC4yIiwKICAgICJAdml0ZXN0L2NvdmVyYWdlLXY4IjogIl40LjEuMCIsCiAgICAiZXNsaW50IjogIl45LjM5LjQiLAogICAgImVzbGludC1jb25maWctcHJldHRpZXIiOiAiXjEwLjEuOCIsCiAgICAiZXNsaW50LXBsdWdpbi1wcmV0dGllciI6ICJeNS41LjUiLAogICAgInByZXR0aWVyIjogIl4zLjYuMiIsCiAgICAidHN4IjogIl40LjIxLjAiLAogICAgInR5cGVzY3JpcHQiOiAiXjUuOS4zIiwKICAgICJ0eXBlc2NyaXB0LWVzbGludCI6ICJeOC41Ny4wIiwKICAgICJ2aXRlIjogIl44LjAuMCIsCiAgICAidml0ZS1wbHVnaW4tZHRzIjogIl40LjUuNCIsCiAgICAidml0ZXN0IjogIl40LjEuMCIKICB9LAogICJkZXBlbmRlbmNpZXMiOiB7CiAgICAiQGlucXVpcmVyL2NvcmUiOiAiXjExLjEuOCIsCiAgICAiQGlucXVpcmVyL3Byb21wdHMiOiAiXjguNC4xIiwKICAgICJjaGFsayI6ICJeNS42LjIiLAogICAgImlucXVpcmVyLWZpbGUtc2VsZWN0b3IiOiAiXjEuMC4xIiwKICAgICJtaW5pbWlzdCI6ICJeMS4yLjgiCiAgfQp9Cg==`,``+{}.url)),`utf8`);return JSON.parse(e).version??`0.0.0`}catch{return`0.0.0`}}var Ue=class extends Q{static command=`help`;static description=l.default.bold(`Show help information about the CLI and its commands`);constructor(e){super(),this.opts=e}async handle(){let e=this.opts.commandRegistry.getCommands().filter(e=>!e.hidden),t=this.opts.cliName??`Bob CLI`,n=this.opts.cliVersion??`0.0.0`,r=He();this.logger.log(`${t} ${l.default.green(n)} (core: ${l.default.yellow(r)})
|
|
5
5
|
|
|
6
6
|
${l.default.yellow(`Usage`)}:
|
|
7
7
|
command [options] [arguments]
|
package/dist/cjs/lib/types.d.ts
CHANGED
|
@@ -23,20 +23,18 @@ export type FlagDefinition<T = any, C extends CustomOptions = CustomOptions> = {
|
|
|
23
23
|
} & {
|
|
24
24
|
parse: (input: any, opts: FlagOpts<any, C>) => T;
|
|
25
25
|
type?: FlagKind;
|
|
26
|
-
ask?: (opts: FlagOpts) => Promise<any>;
|
|
26
|
+
ask?: (opts: FlagOpts<any, C>) => Promise<any>;
|
|
27
27
|
description?: string;
|
|
28
28
|
required?: boolean;
|
|
29
29
|
default?: T | T[] | null | (() => T | T[] | null) | (() => Promise<T | T[] | null>);
|
|
30
30
|
multiple?: boolean;
|
|
31
31
|
help?: string;
|
|
32
32
|
alias?: string | readonly string[];
|
|
33
|
-
handler?: (value: T, opts: FlagOpts) => {
|
|
33
|
+
handler?: (value: T, opts: FlagOpts<any, C>) => {
|
|
34
34
|
shouldStop: boolean;
|
|
35
35
|
} | void;
|
|
36
36
|
};
|
|
37
|
-
export type InitFlagDefinition<T = any, C extends CustomOptions = CustomOptions> =
|
|
38
|
-
parse?: (input: any, opts: FlagOpts<any, C>) => T;
|
|
39
|
-
};
|
|
37
|
+
export type InitFlagDefinition<T = any, C extends CustomOptions = CustomOptions> = Partial<FlagDefinition<T, C>>;
|
|
40
38
|
/** Infers the runtime return type of a flag definition, accounting for `multiple`. */
|
|
41
39
|
export type InferFlagReturn<O> = O extends {
|
|
42
40
|
parse: (...args: any[]) => infer R;
|
package/dist/esm/HelpFlag.d.ts
CHANGED
|
@@ -4,19 +4,17 @@ export declare const HelpCommandFlag: {
|
|
|
4
4
|
} & {
|
|
5
5
|
parse: (input: any, opts: FlagOpts<any, import('./lib/types.js').CustomOptions>) => boolean;
|
|
6
6
|
type?: import('./lib/types.js').FlagKind;
|
|
7
|
-
ask?: (opts: FlagOpts) => Promise<any
|
|
7
|
+
ask?: ((opts: FlagOpts<any, import('./lib/types.js').CustomOptions>) => Promise<any>) | undefined;
|
|
8
8
|
description?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
default?: boolean | boolean[] | (() => boolean | boolean[] | null) | (() => Promise<boolean | boolean[] | null>) | null | undefined;
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
help?: string;
|
|
13
13
|
alias?: string | readonly string[];
|
|
14
|
-
handler?: ((value: boolean, opts: FlagOpts) => {
|
|
14
|
+
handler?: ((value: boolean, opts: FlagOpts<any, import('./lib/types.js').CustomOptions>) => {
|
|
15
15
|
shouldStop: boolean;
|
|
16
16
|
} | void) | undefined;
|
|
17
|
-
} &
|
|
18
|
-
parse?: ((input: any, opts: FlagOpts<any, import('./lib/types.js').CustomOptions>) => boolean) | undefined;
|
|
19
|
-
} & {
|
|
17
|
+
} & Partial<FlagDefinition<boolean, import('./lib/types.js').CustomOptions>> & {
|
|
20
18
|
readonly alias: readonly ["h"];
|
|
21
19
|
readonly description: "Displays help information about the command";
|
|
22
20
|
readonly handler: (value: boolean, opts: FlagOpts) => {
|
package/dist/esm/args/index.d.ts
CHANGED
|
@@ -12,19 +12,17 @@ export declare const Args: {
|
|
|
12
12
|
} & {
|
|
13
13
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => string;
|
|
14
14
|
type?: import('../index.js').FlagKind;
|
|
15
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
15
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
16
16
|
description?: string;
|
|
17
17
|
required?: boolean;
|
|
18
18
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
19
19
|
multiple?: boolean;
|
|
20
20
|
help?: string;
|
|
21
21
|
alias?: string | readonly string[];
|
|
22
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts) => {
|
|
22
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
23
23
|
shouldStop: boolean;
|
|
24
24
|
} | void) | undefined;
|
|
25
|
-
} &
|
|
26
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => string) | undefined;
|
|
27
|
-
} & O;
|
|
25
|
+
} & Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions>> & O;
|
|
28
26
|
number: <const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
29
27
|
min?: number;
|
|
30
28
|
max?: number;
|
|
@@ -37,25 +35,26 @@ export declare const Args: {
|
|
|
37
35
|
max?: number;
|
|
38
36
|
}>) => number;
|
|
39
37
|
type?: import('../index.js').FlagKind;
|
|
40
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
38
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
39
|
+
min?: number;
|
|
40
|
+
max?: number;
|
|
41
|
+
}>) => Promise<any>) | undefined;
|
|
41
42
|
description?: string;
|
|
42
43
|
required?: boolean;
|
|
43
44
|
default?: number | number[] | (() => number | number[] | null) | (() => Promise<number | number[] | null>) | null | undefined;
|
|
44
45
|
multiple?: boolean;
|
|
45
46
|
help?: string;
|
|
46
47
|
alias?: string | readonly string[];
|
|
47
|
-
handler?: ((value: number, opts: import('../index.js').FlagOpts
|
|
48
|
+
handler?: ((value: number, opts: import('../index.js').FlagOpts<any, {
|
|
49
|
+
min?: number;
|
|
50
|
+
max?: number;
|
|
51
|
+
}>) => {
|
|
48
52
|
shouldStop: boolean;
|
|
49
53
|
} | void) | undefined;
|
|
50
|
-
} &
|
|
54
|
+
} & Partial<import('../index.js').FlagDefinition<number, {
|
|
51
55
|
min?: number;
|
|
52
56
|
max?: number;
|
|
53
|
-
}
|
|
54
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
55
|
-
min?: number;
|
|
56
|
-
max?: number;
|
|
57
|
-
}>) => number) | undefined;
|
|
58
|
-
} & O;
|
|
57
|
+
}>> & O;
|
|
59
58
|
option: typeof optionFlag;
|
|
60
59
|
file: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
61
60
|
exists?: boolean;
|
|
@@ -66,23 +65,23 @@ export declare const Args: {
|
|
|
66
65
|
exists?: boolean;
|
|
67
66
|
}>) => string;
|
|
68
67
|
type?: import('../index.js').FlagKind;
|
|
69
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
68
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
69
|
+
exists?: boolean;
|
|
70
|
+
}>) => Promise<any>) | undefined;
|
|
70
71
|
description?: string;
|
|
71
72
|
required?: boolean;
|
|
72
73
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
73
74
|
multiple?: boolean;
|
|
74
75
|
help?: string;
|
|
75
76
|
alias?: string | readonly string[];
|
|
76
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts
|
|
77
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, {
|
|
78
|
+
exists?: boolean;
|
|
79
|
+
}>) => {
|
|
77
80
|
shouldStop: boolean;
|
|
78
81
|
} | void) | undefined;
|
|
79
|
-
} &
|
|
82
|
+
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
80
83
|
exists?: boolean;
|
|
81
|
-
}
|
|
82
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
83
|
-
exists?: boolean;
|
|
84
|
-
}>) => string) | undefined;
|
|
85
|
-
} & O;
|
|
84
|
+
}>> & O;
|
|
86
85
|
directory: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
87
86
|
exists?: boolean;
|
|
88
87
|
}>>>(overrides?: O | undefined) => {
|
|
@@ -92,40 +91,38 @@ export declare const Args: {
|
|
|
92
91
|
exists?: boolean;
|
|
93
92
|
}>) => string;
|
|
94
93
|
type?: import('../index.js').FlagKind;
|
|
95
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
94
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
95
|
+
exists?: boolean;
|
|
96
|
+
}>) => Promise<any>) | undefined;
|
|
96
97
|
description?: string;
|
|
97
98
|
required?: boolean;
|
|
98
99
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
99
100
|
multiple?: boolean;
|
|
100
101
|
help?: string;
|
|
101
102
|
alias?: string | readonly string[];
|
|
102
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts
|
|
103
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, {
|
|
104
|
+
exists?: boolean;
|
|
105
|
+
}>) => {
|
|
103
106
|
shouldStop: boolean;
|
|
104
107
|
} | void) | undefined;
|
|
105
|
-
} &
|
|
108
|
+
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
106
109
|
exists?: boolean;
|
|
107
|
-
}
|
|
108
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
109
|
-
exists?: boolean;
|
|
110
|
-
}>) => string) | undefined;
|
|
111
|
-
} & O;
|
|
110
|
+
}>> & O;
|
|
112
111
|
url: <const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>>>(overrides?: O | undefined) => {
|
|
113
112
|
[x: string]: unknown;
|
|
114
113
|
} & {
|
|
115
114
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => URL;
|
|
116
115
|
type?: import('../index.js').FlagKind;
|
|
117
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
116
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
118
117
|
description?: string;
|
|
119
118
|
required?: boolean;
|
|
120
119
|
default?: URL | URL[] | (() => URL | URL[] | null) | (() => Promise<URL | URL[] | null>) | null | undefined;
|
|
121
120
|
multiple?: boolean;
|
|
122
121
|
help?: string;
|
|
123
122
|
alias?: string | readonly string[];
|
|
124
|
-
handler?: ((value: URL, opts: import('../index.js').FlagOpts) => {
|
|
123
|
+
handler?: ((value: URL, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
125
124
|
shouldStop: boolean;
|
|
126
125
|
} | void) | undefined;
|
|
127
|
-
} &
|
|
128
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => URL) | undefined;
|
|
129
|
-
} & O;
|
|
126
|
+
} & Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>> & O;
|
|
130
127
|
custom: typeof custom;
|
|
131
128
|
};
|
|
@@ -5,16 +5,14 @@ export declare const booleanFlag: <const O extends Partial<import('../lib/types.
|
|
|
5
5
|
} & {
|
|
6
6
|
parse: (input: any, opts: FlagOpts<any, import('../lib/types.js').CustomOptions>) => boolean;
|
|
7
7
|
type?: import('../lib/types.js').FlagKind;
|
|
8
|
-
ask?: (opts: FlagOpts) => Promise<any
|
|
8
|
+
ask?: ((opts: FlagOpts<any, import('../lib/types.js').CustomOptions>) => Promise<any>) | undefined;
|
|
9
9
|
description?: string;
|
|
10
10
|
required?: boolean;
|
|
11
11
|
default?: boolean | boolean[] | (() => boolean | boolean[] | null) | (() => Promise<boolean | boolean[] | null>) | null | undefined;
|
|
12
12
|
multiple?: boolean;
|
|
13
13
|
help?: string;
|
|
14
14
|
alias?: string | readonly string[];
|
|
15
|
-
handler?: ((value: boolean, opts: FlagOpts) => {
|
|
15
|
+
handler?: ((value: boolean, opts: FlagOpts<any, import('../lib/types.js').CustomOptions>) => {
|
|
16
16
|
shouldStop: boolean;
|
|
17
17
|
} | void) | undefined;
|
|
18
|
-
} &
|
|
19
|
-
parse?: ((input: any, opts: FlagOpts<any, import('../lib/types.js').CustomOptions>) => boolean) | undefined;
|
|
20
|
-
} & O;
|
|
18
|
+
} & Partial<import('../lib/types.js').FlagDefinition<boolean, import('../lib/types.js').CustomOptions>> & O;
|
|
@@ -8,20 +8,20 @@ export declare const directoryFlag: <const O extends Partial<import('../index.js
|
|
|
8
8
|
exists?: boolean;
|
|
9
9
|
}>) => string;
|
|
10
10
|
type?: import('../index.js').FlagKind;
|
|
11
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
11
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
12
|
+
exists?: boolean;
|
|
13
|
+
}>) => Promise<any>) | undefined;
|
|
12
14
|
description?: string;
|
|
13
15
|
required?: boolean;
|
|
14
16
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
15
17
|
multiple?: boolean;
|
|
16
18
|
help?: string;
|
|
17
19
|
alias?: string | readonly string[];
|
|
18
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts
|
|
20
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, {
|
|
21
|
+
exists?: boolean;
|
|
22
|
+
}>) => {
|
|
19
23
|
shouldStop: boolean;
|
|
20
24
|
} | void) | undefined;
|
|
21
|
-
} &
|
|
25
|
+
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
22
26
|
exists?: boolean;
|
|
23
|
-
}
|
|
24
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
25
|
-
exists?: boolean;
|
|
26
|
-
}>) => string) | undefined;
|
|
27
|
-
} & O;
|
|
27
|
+
}>> & O;
|
package/dist/esm/flags/file.d.ts
CHANGED
|
@@ -8,20 +8,20 @@ export declare const fileFlag: <const O extends Partial<import('../index.js').Fl
|
|
|
8
8
|
exists?: boolean;
|
|
9
9
|
}>) => string;
|
|
10
10
|
type?: import('../index.js').FlagKind;
|
|
11
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
11
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
12
|
+
exists?: boolean;
|
|
13
|
+
}>) => Promise<any>) | undefined;
|
|
12
14
|
description?: string;
|
|
13
15
|
required?: boolean;
|
|
14
16
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
15
17
|
multiple?: boolean;
|
|
16
18
|
help?: string;
|
|
17
19
|
alias?: string | readonly string[];
|
|
18
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts
|
|
20
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, {
|
|
21
|
+
exists?: boolean;
|
|
22
|
+
}>) => {
|
|
19
23
|
shouldStop: boolean;
|
|
20
24
|
} | void) | undefined;
|
|
21
|
-
} &
|
|
25
|
+
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
22
26
|
exists?: boolean;
|
|
23
|
-
}
|
|
24
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
25
|
-
exists?: boolean;
|
|
26
|
-
}>) => string) | undefined;
|
|
27
|
-
} & O;
|
|
27
|
+
}>> & O;
|
|
@@ -22,19 +22,17 @@ export declare const Flags: {
|
|
|
22
22
|
} & {
|
|
23
23
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => string;
|
|
24
24
|
type?: import('../index.js').FlagKind;
|
|
25
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
25
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
26
26
|
description?: string;
|
|
27
27
|
required?: boolean;
|
|
28
28
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
29
29
|
multiple?: boolean;
|
|
30
30
|
help?: string;
|
|
31
31
|
alias?: string | readonly string[];
|
|
32
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts) => {
|
|
32
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
33
33
|
shouldStop: boolean;
|
|
34
34
|
} | void) | undefined;
|
|
35
|
-
} &
|
|
36
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => string) | undefined;
|
|
37
|
-
} & O;
|
|
35
|
+
} & Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions>> & O;
|
|
38
36
|
number: <const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
39
37
|
min?: number;
|
|
40
38
|
max?: number;
|
|
@@ -47,43 +45,42 @@ export declare const Flags: {
|
|
|
47
45
|
max?: number;
|
|
48
46
|
}>) => number;
|
|
49
47
|
type?: import('../index.js').FlagKind;
|
|
50
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
48
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
49
|
+
min?: number;
|
|
50
|
+
max?: number;
|
|
51
|
+
}>) => Promise<any>) | undefined;
|
|
51
52
|
description?: string;
|
|
52
53
|
required?: boolean;
|
|
53
54
|
default?: number | number[] | (() => number | number[] | null) | (() => Promise<number | number[] | null>) | null | undefined;
|
|
54
55
|
multiple?: boolean;
|
|
55
56
|
help?: string;
|
|
56
57
|
alias?: string | readonly string[];
|
|
57
|
-
handler?: ((value: number, opts: import('../index.js').FlagOpts
|
|
58
|
+
handler?: ((value: number, opts: import('../index.js').FlagOpts<any, {
|
|
59
|
+
min?: number;
|
|
60
|
+
max?: number;
|
|
61
|
+
}>) => {
|
|
58
62
|
shouldStop: boolean;
|
|
59
63
|
} | void) | undefined;
|
|
60
|
-
} &
|
|
64
|
+
} & Partial<import('../index.js').FlagDefinition<number, {
|
|
61
65
|
min?: number;
|
|
62
66
|
max?: number;
|
|
63
|
-
}
|
|
64
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
65
|
-
min?: number;
|
|
66
|
-
max?: number;
|
|
67
|
-
}>) => number) | undefined;
|
|
68
|
-
} & O;
|
|
67
|
+
}>> & O;
|
|
69
68
|
boolean: <const O extends Partial<import('../index.js').FlagDefinition<boolean, import('../index.js').CustomOptions>>>(overrides?: O | undefined) => {
|
|
70
69
|
[x: string]: unknown;
|
|
71
70
|
} & {
|
|
72
71
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => boolean;
|
|
73
72
|
type?: import('../index.js').FlagKind;
|
|
74
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
73
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
75
74
|
description?: string;
|
|
76
75
|
required?: boolean;
|
|
77
76
|
default?: boolean | boolean[] | (() => boolean | boolean[] | null) | (() => Promise<boolean | boolean[] | null>) | null | undefined;
|
|
78
77
|
multiple?: boolean;
|
|
79
78
|
help?: string;
|
|
80
79
|
alias?: string | readonly string[];
|
|
81
|
-
handler?: ((value: boolean, opts: import('../index.js').FlagOpts) => {
|
|
80
|
+
handler?: ((value: boolean, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
82
81
|
shouldStop: boolean;
|
|
83
82
|
} | void) | undefined;
|
|
84
|
-
} &
|
|
85
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => boolean) | undefined;
|
|
86
|
-
} & O;
|
|
83
|
+
} & Partial<import('../index.js').FlagDefinition<boolean, import('../index.js').CustomOptions>> & O;
|
|
87
84
|
option: typeof optionFlag;
|
|
88
85
|
file: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
89
86
|
exists?: boolean;
|
|
@@ -94,23 +91,23 @@ export declare const Flags: {
|
|
|
94
91
|
exists?: boolean;
|
|
95
92
|
}>) => string;
|
|
96
93
|
type?: import('../index.js').FlagKind;
|
|
97
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
94
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
95
|
+
exists?: boolean;
|
|
96
|
+
}>) => Promise<any>) | undefined;
|
|
98
97
|
description?: string;
|
|
99
98
|
required?: boolean;
|
|
100
99
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
101
100
|
multiple?: boolean;
|
|
102
101
|
help?: string;
|
|
103
102
|
alias?: string | readonly string[];
|
|
104
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts
|
|
103
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, {
|
|
104
|
+
exists?: boolean;
|
|
105
|
+
}>) => {
|
|
105
106
|
shouldStop: boolean;
|
|
106
107
|
} | void) | undefined;
|
|
107
|
-
} &
|
|
108
|
+
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
108
109
|
exists?: boolean;
|
|
109
|
-
}
|
|
110
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
111
|
-
exists?: boolean;
|
|
112
|
-
}>) => string) | undefined;
|
|
113
|
-
} & O;
|
|
110
|
+
}>> & O;
|
|
114
111
|
directory: <const O extends Partial<import('../index.js').FlagDefinition<string, {
|
|
115
112
|
exists?: boolean;
|
|
116
113
|
}>>>(overrides?: O | undefined) => {
|
|
@@ -120,41 +117,39 @@ export declare const Flags: {
|
|
|
120
117
|
exists?: boolean;
|
|
121
118
|
}>) => string;
|
|
122
119
|
type?: import('../index.js').FlagKind;
|
|
123
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
120
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
121
|
+
exists?: boolean;
|
|
122
|
+
}>) => Promise<any>) | undefined;
|
|
124
123
|
description?: string;
|
|
125
124
|
required?: boolean;
|
|
126
125
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
127
126
|
multiple?: boolean;
|
|
128
127
|
help?: string;
|
|
129
128
|
alias?: string | readonly string[];
|
|
130
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts
|
|
129
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, {
|
|
130
|
+
exists?: boolean;
|
|
131
|
+
}>) => {
|
|
131
132
|
shouldStop: boolean;
|
|
132
133
|
} | void) | undefined;
|
|
133
|
-
} &
|
|
134
|
+
} & Partial<import('../index.js').FlagDefinition<string, {
|
|
134
135
|
exists?: boolean;
|
|
135
|
-
}
|
|
136
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
137
|
-
exists?: boolean;
|
|
138
|
-
}>) => string) | undefined;
|
|
139
|
-
} & O;
|
|
136
|
+
}>> & O;
|
|
140
137
|
url: <const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>>>(overrides?: O | undefined) => {
|
|
141
138
|
[x: string]: unknown;
|
|
142
139
|
} & {
|
|
143
140
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => URL;
|
|
144
141
|
type?: import('../index.js').FlagKind;
|
|
145
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
142
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
146
143
|
description?: string;
|
|
147
144
|
required?: boolean;
|
|
148
145
|
default?: URL | URL[] | (() => URL | URL[] | null) | (() => Promise<URL | URL[] | null>) | null | undefined;
|
|
149
146
|
multiple?: boolean;
|
|
150
147
|
help?: string;
|
|
151
148
|
alias?: string | readonly string[];
|
|
152
|
-
handler?: ((value: URL, opts: import('../index.js').FlagOpts) => {
|
|
149
|
+
handler?: ((value: URL, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
153
150
|
shouldStop: boolean;
|
|
154
151
|
} | void) | undefined;
|
|
155
|
-
} &
|
|
156
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => URL) | undefined;
|
|
157
|
-
} & O;
|
|
152
|
+
} & Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>> & O;
|
|
158
153
|
custom: typeof custom;
|
|
159
154
|
};
|
|
160
155
|
export { Args } from '../args/index.js';
|
|
@@ -11,22 +11,23 @@ export declare const numberFlag: <const O extends Partial<import('../index.js').
|
|
|
11
11
|
max?: number;
|
|
12
12
|
}>) => number;
|
|
13
13
|
type?: import('../index.js').FlagKind;
|
|
14
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
14
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, {
|
|
15
|
+
min?: number;
|
|
16
|
+
max?: number;
|
|
17
|
+
}>) => Promise<any>) | undefined;
|
|
15
18
|
description?: string;
|
|
16
19
|
required?: boolean;
|
|
17
20
|
default?: number | number[] | (() => number | number[] | null) | (() => Promise<number | number[] | null>) | null | undefined;
|
|
18
21
|
multiple?: boolean;
|
|
19
22
|
help?: string;
|
|
20
23
|
alias?: string | readonly string[];
|
|
21
|
-
handler?: ((value: number, opts: import('../index.js').FlagOpts
|
|
24
|
+
handler?: ((value: number, opts: import('../index.js').FlagOpts<any, {
|
|
25
|
+
min?: number;
|
|
26
|
+
max?: number;
|
|
27
|
+
}>) => {
|
|
22
28
|
shouldStop: boolean;
|
|
23
29
|
} | void) | undefined;
|
|
24
|
-
} &
|
|
30
|
+
} & Partial<import('../index.js').FlagDefinition<number, {
|
|
25
31
|
min?: number;
|
|
26
32
|
max?: number;
|
|
27
|
-
}
|
|
28
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, {
|
|
29
|
-
min?: number;
|
|
30
|
-
max?: number;
|
|
31
|
-
}>) => number) | undefined;
|
|
32
|
-
} & O;
|
|
33
|
+
}>> & O;
|
|
@@ -4,16 +4,14 @@ export declare const stringFlag: <const O extends Partial<import('../index.js').
|
|
|
4
4
|
} & {
|
|
5
5
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => string;
|
|
6
6
|
type?: import('../index.js').FlagKind;
|
|
7
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
7
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
8
8
|
description?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
help?: string;
|
|
13
13
|
alias?: string | readonly string[];
|
|
14
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts) => {
|
|
14
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
15
15
|
shouldStop: boolean;
|
|
16
16
|
} | void) | undefined;
|
|
17
|
-
} &
|
|
18
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => string) | undefined;
|
|
19
|
-
} & O;
|
|
17
|
+
} & Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions>> & O;
|
package/dist/esm/flags/url.d.ts
CHANGED
|
@@ -4,16 +4,14 @@ export declare const urlFlag: <const O extends Partial<import('../index.js').Fla
|
|
|
4
4
|
} & {
|
|
5
5
|
parse: (input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => URL;
|
|
6
6
|
type?: import('../index.js').FlagKind;
|
|
7
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
7
|
+
ask?: ((opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
8
8
|
description?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
default?: URL | URL[] | (() => URL | URL[] | null) | (() => Promise<URL | URL[] | null>) | null | undefined;
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
help?: string;
|
|
13
13
|
alias?: string | readonly string[];
|
|
14
|
-
handler?: ((value: URL, opts: import('../index.js').FlagOpts) => {
|
|
14
|
+
handler?: ((value: URL, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => {
|
|
15
15
|
shouldStop: boolean;
|
|
16
16
|
} | void) | undefined;
|
|
17
|
-
} &
|
|
18
|
-
parse?: ((input: any, opts: import('../index.js').FlagOpts<any, import('../index.js').CustomOptions>) => URL) | undefined;
|
|
19
|
-
} & O;
|
|
17
|
+
} & Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>> & O;
|
package/dist/esm/index.js
CHANGED
|
@@ -1160,7 +1160,7 @@ var Ke = .75, qe = .55, Je = .05, Ye = class {
|
|
|
1160
1160
|
}, Ze = /* @__PURE__ */ ue(Ne(), 1);
|
|
1161
1161
|
function Qe() {
|
|
1162
1162
|
try {
|
|
1163
|
-
let e = n((0, Ze.fileURLToPath)(new URL("data:application/json;base64,
|
|
1163
|
+
let e = n((0, Ze.fileURLToPath)(new URL("data:application/json;base64,ewogICJuYW1lIjogImJvYi1jb3JlIiwKICAidmVyc2lvbiI6ICIzLjAuMC1iZXRhLjkiLAogICJkZXNjcmlwdGlvbiI6ICJCT0IgQ29yZSIsCiAgInR5cGUiOiAibW9kdWxlIiwKICAibWFpbiI6ICIuL2Rpc3QvY2pzL2luZGV4LmpzIiwKICAibW9kdWxlIjogIi4vZGlzdC9lc20vaW5kZXguanMiLAogICJ0eXBlcyI6ICIuL2Rpc3QvZXNtL2luZGV4LmQudHMiLAogICJmaWxlcyI6IFsKICAgICJkaXN0IgogIF0sCiAgImV4cG9ydHMiOiB7CiAgICAiLiI6IHsKICAgICAgImltcG9ydCI6IHsKICAgICAgICAidHlwZXMiOiAiLi9kaXN0L2VzbS9pbmRleC5kLnRzIiwKICAgICAgICAiZGVmYXVsdCI6ICIuL2Rpc3QvZXNtL2luZGV4LmpzIgogICAgICB9LAogICAgICAicmVxdWlyZSI6IHsKICAgICAgICAidHlwZXMiOiAiLi9kaXN0L2Nqcy9pbmRleC5kLnRzIiwKICAgICAgICAiZGVmYXVsdCI6ICIuL2Rpc3QvY2pzL2luZGV4LmpzIgogICAgICB9CiAgICB9CiAgfSwKICAic2NyaXB0cyI6IHsKICAgICJzdGFydCI6ICJub2RlIC1yIEBzd2Mtbm9kZS9yZWdpc3RlciBkZWJ1Zy9tYWluLnRzIiwKICAgICJidWlsZCI6ICJybSAtcmYgLi9kaXN0ICYmIHZpdGUgYnVpbGQiLAogICAgInR5cGVjaGVjayI6ICJ0c2MgLS1ub0VtaXQiLAogICAgInByZXBhY2siOiAibnBtIHJ1biBidWlsZCIsCiAgICAidGVzdCI6ICJ2aXRlc3QgcnVuIiwKICAgICJsaW50IjogImVzbGludCAuIiwKICAgICJsaW50OmZpeCI6ICJlc2xpbnQgLiAtLWZpeCIKICB9LAogICJhdXRob3IiOiAiTMOpbyBIdWJlcnQiLAogICJsaWNlbnNlIjogIklTQyIsCiAgImRldkRlcGVuZGVuY2llcyI6IHsKICAgICJAZXNsaW50L2pzIjogIl45LjM5LjQiLAogICAgIkBmYWtlci1qcy9mYWtlciI6ICJeMTAuMy4wIiwKICAgICJAc3djLW5vZGUvcmVnaXN0ZXIiOiAiXjEuMTEuMSIsCiAgICAiQHRyaXZhZ28vcHJldHRpZXItcGx1Z2luLXNvcnQtaW1wb3J0cyI6ICJeNS4yLjIiLAogICAgIkB0eXBlcy9taW5pbWlzdCI6ICJeMS4yLjUiLAogICAgIkB0eXBlcy9ub2RlIjogIl4yMC4xNC41IiwKICAgICJAdHlwZXMvc3RyaW5nLXNpbWlsYXJpdHkiOiAiXjQuMC4yIiwKICAgICJAdml0ZXN0L2NvdmVyYWdlLXY4IjogIl40LjEuMCIsCiAgICAiZXNsaW50IjogIl45LjM5LjQiLAogICAgImVzbGludC1jb25maWctcHJldHRpZXIiOiAiXjEwLjEuOCIsCiAgICAiZXNsaW50LXBsdWdpbi1wcmV0dGllciI6ICJeNS41LjUiLAogICAgInByZXR0aWVyIjogIl4zLjYuMiIsCiAgICAidHN4IjogIl40LjIxLjAiLAogICAgInR5cGVzY3JpcHQiOiAiXjUuOS4zIiwKICAgICJ0eXBlc2NyaXB0LWVzbGludCI6ICJeOC41Ny4wIiwKICAgICJ2aXRlIjogIl44LjAuMCIsCiAgICAidml0ZS1wbHVnaW4tZHRzIjogIl40LjUuNCIsCiAgICAidml0ZXN0IjogIl40LjEuMCIKICB9LAogICJkZXBlbmRlbmNpZXMiOiB7CiAgICAiQGlucXVpcmVyL2NvcmUiOiAiXjExLjEuOCIsCiAgICAiQGlucXVpcmVyL3Byb21wdHMiOiAiXjguNC4xIiwKICAgICJjaGFsayI6ICJeNS42LjIiLAogICAgImlucXVpcmVyLWZpbGUtc2VsZWN0b3IiOiAiXjEuMC4xIiwKICAgICJtaW5pbWlzdCI6ICJeMS4yLjgiCiAgfQp9Cg==", "" + import.meta.url)), "utf8");
|
|
1164
1164
|
return JSON.parse(e).version ?? "0.0.0";
|
|
1165
1165
|
} catch {
|
|
1166
1166
|
return "0.0.0";
|
package/dist/esm/lib/types.d.ts
CHANGED
|
@@ -23,20 +23,18 @@ export type FlagDefinition<T = any, C extends CustomOptions = CustomOptions> = {
|
|
|
23
23
|
} & {
|
|
24
24
|
parse: (input: any, opts: FlagOpts<any, C>) => T;
|
|
25
25
|
type?: FlagKind;
|
|
26
|
-
ask?: (opts: FlagOpts) => Promise<any>;
|
|
26
|
+
ask?: (opts: FlagOpts<any, C>) => Promise<any>;
|
|
27
27
|
description?: string;
|
|
28
28
|
required?: boolean;
|
|
29
29
|
default?: T | T[] | null | (() => T | T[] | null) | (() => Promise<T | T[] | null>);
|
|
30
30
|
multiple?: boolean;
|
|
31
31
|
help?: string;
|
|
32
32
|
alias?: string | readonly string[];
|
|
33
|
-
handler?: (value: T, opts: FlagOpts) => {
|
|
33
|
+
handler?: (value: T, opts: FlagOpts<any, C>) => {
|
|
34
34
|
shouldStop: boolean;
|
|
35
35
|
} | void;
|
|
36
36
|
};
|
|
37
|
-
export type InitFlagDefinition<T = any, C extends CustomOptions = CustomOptions> =
|
|
38
|
-
parse?: (input: any, opts: FlagOpts<any, C>) => T;
|
|
39
|
-
};
|
|
37
|
+
export type InitFlagDefinition<T = any, C extends CustomOptions = CustomOptions> = Partial<FlagDefinition<T, C>>;
|
|
40
38
|
/** Infers the runtime return type of a flag definition, accounting for `multiple`. */
|
|
41
39
|
export type InferFlagReturn<O> = O extends {
|
|
42
40
|
parse: (...args: any[]) => infer R;
|