convoker 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/chunk-z5eko27R.mjs +13 -0
- package/dist/color/index.d.mts +2 -0
- package/dist/color/index.mjs +3 -0
- package/dist/color-DiZvJ0Fc.mjs +201 -0
- package/dist/color-DiZvJ0Fc.mjs.map +1 -0
- package/dist/command/index.d.mts +5 -0
- package/dist/command/index.mjs +8 -0
- package/dist/command-8P8qXJ2o.mjs +486 -0
- package/dist/command-8P8qXJ2o.mjs.map +1 -0
- package/dist/index-BYLskLxk.d.mts +200 -0
- package/dist/index-BtbthYjp.d.mts +168 -0
- package/dist/index-ClhbwSD8.d.mts +202 -0
- package/dist/index-Cnx4H4D-.d.mts +316 -0
- package/dist/index.d.mts +37 -0
- package/dist/index.mjs +92 -0
- package/dist/index.mjs.map +1 -0
- package/dist/input/index.d.mts +3 -0
- package/dist/input/index.mjs +4 -0
- package/dist/input-XUsy1LCQ.mjs +176 -0
- package/dist/input-XUsy1LCQ.mjs.map +1 -0
- package/dist/prompt/index.d.mts +5 -0
- package/dist/prompt/index.mjs +6 -0
- package/dist/prompt/raw.d.mts +2 -0
- package/dist/prompt/raw.mjs +3 -0
- package/dist/prompt-a5Ix_Hyc.mjs +220 -0
- package/dist/prompt-a5Ix_Hyc.mjs.map +1 -0
- package/dist/raw-DEtZFeMv.mjs +88 -0
- package/dist/raw-DEtZFeMv.mjs.map +1 -0
- package/dist/raw-cqTp2vds.d.mts +38 -0
- package/dist/standard-schema-DTuaYJjO.mjs +32 -0
- package/dist/standard-schema-DTuaYJjO.mjs.map +1 -0
- package/dist/standard-schema-DXS-QnwX.d.mts +59 -0
- package/package.json +24 -26
- package/dist/color.d.ts +0 -153
- package/dist/color.js +0 -143
- package/dist/command.d.ts +0 -218
- package/dist/command.js +0 -531
- package/dist/error.d.ts +0 -107
- package/dist/error.js +0 -100
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -6
- package/dist/input.d.ts +0 -182
- package/dist/input.js +0 -185
- package/dist/log.d.ts +0 -61
- package/dist/log.js +0 -216
- package/dist/prompt/index.d.ts +0 -193
- package/dist/prompt/index.js +0 -273
- package/dist/prompt/raw.d.ts +0 -32
- package/dist/prompt/raw.js +0 -105
- package/dist/standard-schema.d.ts +0 -62
- package/dist/standard-schema.js +0 -16
- package/dist/utils.d.ts +0 -30
- package/dist/utils.js +0 -56
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { n as Theme } from "./index-BtbthYjp.mjs";
|
|
2
|
+
import { t as StandardSchemaV1 } from "./standard-schema-DXS-QnwX.mjs";
|
|
3
|
+
import { i as raw_d_exports } from "./raw-cqTp2vds.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/prompt/index.d.ts
|
|
6
|
+
declare namespace index_d_exports {
|
|
7
|
+
export { BaseOpts, ConfirmOpts, EditorOpts, PasswordOpts, SearchOpts, SelectOption, SelectOpts, TextOpts, confirm, editor, multiselect, password, raw_d_exports as raw, search, select, setTheme, text };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Sets the theme of the prompts.
|
|
11
|
+
* @param t The new theme.
|
|
12
|
+
*/
|
|
13
|
+
declare function setTheme(t: Theme): void;
|
|
14
|
+
/**
|
|
15
|
+
* Base options for prompts.
|
|
16
|
+
*/
|
|
17
|
+
interface BaseOpts<T> {
|
|
18
|
+
/**
|
|
19
|
+
* The message of the prompt.
|
|
20
|
+
*/
|
|
21
|
+
message: string;
|
|
22
|
+
/**
|
|
23
|
+
* An `AbortSignal` to cancel the prompt.
|
|
24
|
+
*/
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
/**
|
|
27
|
+
* The default value.
|
|
28
|
+
*/
|
|
29
|
+
default?: T;
|
|
30
|
+
/**
|
|
31
|
+
* The theme of the prompt.
|
|
32
|
+
*/
|
|
33
|
+
theme?: Theme;
|
|
34
|
+
/**
|
|
35
|
+
* A validator function, or a Standard Schema validator.
|
|
36
|
+
*/
|
|
37
|
+
validate?: StandardSchemaV1<any, T> | ((value: T) => boolean | T);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Options for text input.
|
|
41
|
+
*/
|
|
42
|
+
interface TextOpts extends BaseOpts<string> {
|
|
43
|
+
/**
|
|
44
|
+
* A placeholder, displayed when the user hasn't typed anything yet.
|
|
45
|
+
*/
|
|
46
|
+
placeholder?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Minimum length of the input.
|
|
49
|
+
*/
|
|
50
|
+
minLength?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Maximum length of the input.
|
|
53
|
+
*/
|
|
54
|
+
maxLength?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Prompts the user for text input.
|
|
58
|
+
* @param opts Options for text input.
|
|
59
|
+
* @returns The text the user typed in, or the default.
|
|
60
|
+
*/
|
|
61
|
+
declare function text(opts: TextOpts): Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Options for password input.
|
|
64
|
+
*/
|
|
65
|
+
interface PasswordOpts extends TextOpts {
|
|
66
|
+
/**
|
|
67
|
+
* The mask for the password input.
|
|
68
|
+
*/
|
|
69
|
+
mask?: string;
|
|
70
|
+
/**
|
|
71
|
+
* If the user should be asked to confirm the password, by typing it again.
|
|
72
|
+
*/
|
|
73
|
+
confirm?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Prompts the user for a password.
|
|
77
|
+
* @param opts Options for password input.
|
|
78
|
+
* @returns The password.
|
|
79
|
+
*/
|
|
80
|
+
declare function password(opts: PasswordOpts): Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
* An option for select input.
|
|
83
|
+
*/
|
|
84
|
+
interface SelectOption<T> {
|
|
85
|
+
/**
|
|
86
|
+
* The label (what gets displayed) of the select option.
|
|
87
|
+
*/
|
|
88
|
+
label: string;
|
|
89
|
+
/**
|
|
90
|
+
* The value (what gets returned) of the select option.
|
|
91
|
+
*/
|
|
92
|
+
value: T;
|
|
93
|
+
/**
|
|
94
|
+
* A description of the option.
|
|
95
|
+
*/
|
|
96
|
+
hint?: string;
|
|
97
|
+
/**
|
|
98
|
+
* If this option is disabled.
|
|
99
|
+
*/
|
|
100
|
+
disabled?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Options for select input.
|
|
104
|
+
*/
|
|
105
|
+
interface SelectOpts<T> extends BaseOpts<T> {
|
|
106
|
+
/**
|
|
107
|
+
* Every option the user can pick from.
|
|
108
|
+
*/
|
|
109
|
+
options: SelectOption<T>[];
|
|
110
|
+
/**
|
|
111
|
+
* The initial option selected.
|
|
112
|
+
*/
|
|
113
|
+
initialIndex?: number;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Prompts the user to select a single option.
|
|
117
|
+
* @param opts Options for select input.
|
|
118
|
+
* @returns The selected option's value.
|
|
119
|
+
*/
|
|
120
|
+
declare function select<T>(opts: SelectOpts<T>): Promise<T>;
|
|
121
|
+
/**
|
|
122
|
+
* Prompts the user to select multiple options.
|
|
123
|
+
* @param opts Options for select input.
|
|
124
|
+
* @returns The selected options.
|
|
125
|
+
*/
|
|
126
|
+
declare function multiselect<T>(opts: SelectOpts<T>): Promise<T[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Options for search input.
|
|
129
|
+
*/
|
|
130
|
+
interface SearchOpts<T> extends BaseOpts<T> {
|
|
131
|
+
/**
|
|
132
|
+
* Every option the user can search through.
|
|
133
|
+
*/
|
|
134
|
+
options: SelectOption<T>[];
|
|
135
|
+
/**
|
|
136
|
+
* Placeholder for the search input.
|
|
137
|
+
*/
|
|
138
|
+
placeholder?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Minimum length for a query string.
|
|
141
|
+
*/
|
|
142
|
+
minQueryLength?: number;
|
|
143
|
+
/**
|
|
144
|
+
* Filters a single option.
|
|
145
|
+
* @param query The search query.
|
|
146
|
+
* @param option The option to filter.
|
|
147
|
+
*/
|
|
148
|
+
filter?(query: string, option: SelectOption<T>): boolean;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Prompts the user to search through a list of options.
|
|
152
|
+
* @param opts Options for search input.
|
|
153
|
+
* @returns The selected option.
|
|
154
|
+
*/
|
|
155
|
+
declare function search<T>(opts: SearchOpts<T>): Promise<T>;
|
|
156
|
+
/**
|
|
157
|
+
* Options for confirm input.
|
|
158
|
+
*/
|
|
159
|
+
interface ConfirmOpts extends BaseOpts<boolean> {
|
|
160
|
+
/**
|
|
161
|
+
* What gets displayed for the Yes option.
|
|
162
|
+
*/
|
|
163
|
+
yesLabel?: string;
|
|
164
|
+
/**
|
|
165
|
+
* What gets displayed for the No option.
|
|
166
|
+
*/
|
|
167
|
+
noLabel?: string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Prompts the user to confirm an action.
|
|
171
|
+
* @param opts Options for confirm input.
|
|
172
|
+
* @returns If the user picked Yes.
|
|
173
|
+
*/
|
|
174
|
+
declare function confirm(opts: ConfirmOpts): Promise<boolean>;
|
|
175
|
+
/**
|
|
176
|
+
* Options for opening the system editor.
|
|
177
|
+
*/
|
|
178
|
+
interface EditorOpts extends BaseOpts<string> {
|
|
179
|
+
/**
|
|
180
|
+
* The initial value.
|
|
181
|
+
*/
|
|
182
|
+
initial?: string;
|
|
183
|
+
/**
|
|
184
|
+
* The language of the value.
|
|
185
|
+
*/
|
|
186
|
+
language?: string;
|
|
187
|
+
/**
|
|
188
|
+
* If the input is required for continuing or not.
|
|
189
|
+
*/
|
|
190
|
+
required?: boolean;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Opens the system editor, or asks for input in the terminal as fallback.
|
|
194
|
+
* @param opts Options for opening the system editor.
|
|
195
|
+
* @returns The result of the system editor.
|
|
196
|
+
*/
|
|
197
|
+
declare function editor(opts: EditorOpts): Promise<string>;
|
|
198
|
+
//#endregion
|
|
199
|
+
export { text as _, SearchOpts as a, TextOpts as c, index_d_exports as d, multiselect as f, setTheme as g, select as h, PasswordOpts as i, confirm as l, search as m, ConfirmOpts as n, SelectOption as o, password as p, EditorOpts as r, SelectOpts as s, BaseOpts as t, editor as u };
|
|
200
|
+
//# sourceMappingURL=index-BYLskLxk.d.mts.map
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
//#region src/utils.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Deep `Partial<T>`.
|
|
4
|
+
*/
|
|
5
|
+
type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]> };
|
|
6
|
+
declare namespace index_d_exports {
|
|
7
|
+
export { DEFAULT_THEME, Theme, bgBlack, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blue, blueBright, bold, createAnsiColor, cyan, cyanBright, defineTheme, dim, gray, green, greenBright, hidden, inverse, italic, magenta, magentaBright, overline, red, redBright, reset, strikethrough, supportsColor, underline, white, whiteBright, yellow, yellowBright };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* If the runtime supports color.
|
|
11
|
+
*/
|
|
12
|
+
declare const supportsColor: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a function that wraps a string in ANSI codes.
|
|
15
|
+
* @param open The opening ANSI code.
|
|
16
|
+
* @param close The closing ANSI code.
|
|
17
|
+
* @returns A function that wraps the string in ANSI codes.
|
|
18
|
+
*/
|
|
19
|
+
declare function createAnsiColor(open: number, close: number): (input: any) => string;
|
|
20
|
+
declare const reset: (input: any) => string;
|
|
21
|
+
declare const bold: (input: any) => string;
|
|
22
|
+
declare const dim: (input: any) => string;
|
|
23
|
+
declare const italic: (input: any) => string;
|
|
24
|
+
declare const underline: (input: any) => string;
|
|
25
|
+
declare const overline: (input: any) => string;
|
|
26
|
+
declare const inverse: (input: any) => string;
|
|
27
|
+
declare const hidden: (input: any) => string;
|
|
28
|
+
declare const strikethrough: (input: any) => string;
|
|
29
|
+
declare const black: (input: any) => string;
|
|
30
|
+
declare const red: (input: any) => string;
|
|
31
|
+
declare const green: (input: any) => string;
|
|
32
|
+
declare const yellow: (input: any) => string;
|
|
33
|
+
declare const blue: (input: any) => string;
|
|
34
|
+
declare const magenta: (input: any) => string;
|
|
35
|
+
declare const cyan: (input: any) => string;
|
|
36
|
+
declare const white: (input: any) => string;
|
|
37
|
+
declare const gray: (input: any) => string;
|
|
38
|
+
declare const bgBlack: (input: any) => string;
|
|
39
|
+
declare const bgRed: (input: any) => string;
|
|
40
|
+
declare const bgGreen: (input: any) => string;
|
|
41
|
+
declare const bgYellow: (input: any) => string;
|
|
42
|
+
declare const bgBlue: (input: any) => string;
|
|
43
|
+
declare const bgMagenta: (input: any) => string;
|
|
44
|
+
declare const bgCyan: (input: any) => string;
|
|
45
|
+
declare const bgWhite: (input: any) => string;
|
|
46
|
+
declare const bgGray: (input: any) => string;
|
|
47
|
+
declare const redBright: (input: any) => string;
|
|
48
|
+
declare const greenBright: (input: any) => string;
|
|
49
|
+
declare const yellowBright: (input: any) => string;
|
|
50
|
+
declare const blueBright: (input: any) => string;
|
|
51
|
+
declare const magentaBright: (input: any) => string;
|
|
52
|
+
declare const cyanBright: (input: any) => string;
|
|
53
|
+
declare const whiteBright: (input: any) => string;
|
|
54
|
+
declare const bgRedBright: (input: any) => string;
|
|
55
|
+
declare const bgGreenBright: (input: any) => string;
|
|
56
|
+
declare const bgYellowBright: (input: any) => string;
|
|
57
|
+
declare const bgBlueBright: (input: any) => string;
|
|
58
|
+
declare const bgMagentaBright: (input: any) => string;
|
|
59
|
+
declare const bgCyanBright: (input: any) => string;
|
|
60
|
+
declare const bgWhiteBright: (input: any) => string;
|
|
61
|
+
/**
|
|
62
|
+
* A theme.
|
|
63
|
+
*/
|
|
64
|
+
interface Theme {
|
|
65
|
+
/**
|
|
66
|
+
* Wraps a string in a background ANSI code.
|
|
67
|
+
* @param a The string to wrap.
|
|
68
|
+
*/
|
|
69
|
+
background?(a: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Wraps a string in a foreground ANSI code.
|
|
72
|
+
* @param a The string to wrap.
|
|
73
|
+
*/
|
|
74
|
+
foreground?(a: string): string;
|
|
75
|
+
/**
|
|
76
|
+
* Wraps a string in a primary ANSI code.
|
|
77
|
+
* @param a The string to wrap.
|
|
78
|
+
*/
|
|
79
|
+
primary(a: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Wraps a string in a secondary ANSI code.
|
|
82
|
+
* @param a The string to wrap.
|
|
83
|
+
*/
|
|
84
|
+
secondary(a: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* Wraps a string in a accent ANSI code.
|
|
87
|
+
* @param a The string to wrap.
|
|
88
|
+
*/
|
|
89
|
+
accent?(a: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Wraps a string in a success ANSI code.
|
|
92
|
+
* @param a The string to wrap.
|
|
93
|
+
*/
|
|
94
|
+
success(a: string): string;
|
|
95
|
+
/**
|
|
96
|
+
* Wraps a string in a warning ANSI code.
|
|
97
|
+
* @param a The string to wrap.
|
|
98
|
+
*/
|
|
99
|
+
warning(a: string): string;
|
|
100
|
+
/**
|
|
101
|
+
* Wraps a string in a error ANSI code.
|
|
102
|
+
* @param a The string to wrap.
|
|
103
|
+
*/
|
|
104
|
+
error(a: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Wraps a string in a info ANSI code.
|
|
107
|
+
* @param a The string to wrap.
|
|
108
|
+
*/
|
|
109
|
+
info?(a: string): string;
|
|
110
|
+
/**
|
|
111
|
+
* Set of symbols for logging.
|
|
112
|
+
*/
|
|
113
|
+
symbols?: {
|
|
114
|
+
/**
|
|
115
|
+
* Success message symbol.
|
|
116
|
+
*/
|
|
117
|
+
success: string;
|
|
118
|
+
/**
|
|
119
|
+
* Error message symbol.
|
|
120
|
+
*/
|
|
121
|
+
error: string;
|
|
122
|
+
/**
|
|
123
|
+
* Fatal error message symbol.
|
|
124
|
+
*/
|
|
125
|
+
fatal: string;
|
|
126
|
+
/**
|
|
127
|
+
* Warning message symbol.
|
|
128
|
+
*/
|
|
129
|
+
warning: string;
|
|
130
|
+
/**
|
|
131
|
+
* Information message symbol.
|
|
132
|
+
*/
|
|
133
|
+
info?: string;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Optional styles.
|
|
137
|
+
*/
|
|
138
|
+
styles?: {
|
|
139
|
+
/**
|
|
140
|
+
* Wraps a string in a bold ANSI code.
|
|
141
|
+
* @param a The string to wrap.
|
|
142
|
+
*/
|
|
143
|
+
bold?(a: string): string;
|
|
144
|
+
/**
|
|
145
|
+
* Wraps a string in an italic ANSI code.
|
|
146
|
+
* @param a The string to wrap.
|
|
147
|
+
*/
|
|
148
|
+
italic?(a: string): string;
|
|
149
|
+
/**
|
|
150
|
+
* Wraps a string in an underline ANSI code.
|
|
151
|
+
* @param a The string to wrap.
|
|
152
|
+
*/
|
|
153
|
+
underline?(a: string): string;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The default theme.
|
|
158
|
+
*/
|
|
159
|
+
declare const DEFAULT_THEME: Theme;
|
|
160
|
+
/**
|
|
161
|
+
* Defines a theme.
|
|
162
|
+
* @param theme The (partial) theme.
|
|
163
|
+
* @returns The theme, merged with the default theme.
|
|
164
|
+
*/
|
|
165
|
+
declare function defineTheme(theme: DeepPartial<Theme>): Theme;
|
|
166
|
+
//#endregion
|
|
167
|
+
export { greenBright as A, reset as B, createAnsiColor as C, dim as D, defineTheme as E, magenta as F, whiteBright as G, supportsColor as H, magentaBright as I, DeepPartial as J, yellow as K, overline as L, index_d_exports as M, inverse as N, gray as O, italic as P, red as R, bold as S, cyanBright as T, underline as U, strikethrough as V, white as W, bgYellow as _, bgBlueBright as a, blue as b, bgGray as c, bgMagenta as d, bgMagentaBright as f, bgWhiteBright as g, bgWhite as h, bgBlue as i, hidden as j, green as k, bgGreen as l, bgRedBright as m, Theme as n, bgCyan as o, bgRed as p, yellowBright as q, bgBlack as r, bgCyanBright as s, DEFAULT_THEME as t, bgGreenBright as u, bgYellowBright as v, cyan as w, blueBright as x, black as y, redBright as z };
|
|
168
|
+
//# sourceMappingURL=index-BtbthYjp.d.mts.map
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { t as StandardSchemaV1 } from "./standard-schema-DXS-QnwX.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/input/error.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Thrown when the command fails to validate an input.
|
|
6
|
+
*/
|
|
7
|
+
declare class InputValidationError extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* A list of messages.
|
|
10
|
+
*/
|
|
11
|
+
messages: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new input validation error.
|
|
14
|
+
* @param messages The messages.
|
|
15
|
+
*/
|
|
16
|
+
constructor(messages: string[]);
|
|
17
|
+
}
|
|
18
|
+
declare namespace index_d_exports {
|
|
19
|
+
export { BasicKind, InferEntry, InferInput, Input, InputValidationError, Kind, Option, Positional, TypeOf, argument, convert, option, positional };
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* An input object.
|
|
23
|
+
*/
|
|
24
|
+
interface Input {
|
|
25
|
+
[x: string]: Option<any, any, any> | Positional<any, any, any>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A basic input type.
|
|
29
|
+
*/
|
|
30
|
+
type BasicKind = "boolean" | "string" | "number" | "bigint";
|
|
31
|
+
/**
|
|
32
|
+
* An input type.
|
|
33
|
+
*/
|
|
34
|
+
type Kind = BasicKind | StandardSchemaV1<any, any>;
|
|
35
|
+
/**
|
|
36
|
+
* Converts a Kind to a TypeScript type.
|
|
37
|
+
*/
|
|
38
|
+
type TypeOf<T extends Kind> = T extends StandardSchemaV1<any, infer Out> ? Out : T extends "boolean" ? boolean : T extends "string" ? string : T extends "number" ? number : T extends "bigint" ? bigint : never;
|
|
39
|
+
/**
|
|
40
|
+
* Infers TypeScript types from an input object.
|
|
41
|
+
*/
|
|
42
|
+
type InferInput<T extends Input> = { [K in keyof T]: InferEntry<T[K]> };
|
|
43
|
+
/**
|
|
44
|
+
* Infers a TypeScript type from an option or positional.
|
|
45
|
+
*/
|
|
46
|
+
type InferEntry<T> = T extends {
|
|
47
|
+
$kind: infer TKind extends Kind;
|
|
48
|
+
$required: infer Required;
|
|
49
|
+
$list: infer List;
|
|
50
|
+
} ? List extends true ? Required extends true ? TypeOf<TKind>[] : TypeOf<TKind>[] | undefined : Required extends true ? TypeOf<TKind> : TypeOf<TKind> | undefined : never;
|
|
51
|
+
/**
|
|
52
|
+
* Converts a value from a Kind to a TypeScript type.
|
|
53
|
+
* @param kind The kind to convert to.
|
|
54
|
+
* @param value The value to convert.
|
|
55
|
+
* @returns The converted value.
|
|
56
|
+
*/
|
|
57
|
+
declare function convert<TKind$1 extends Kind>(kind: TKind$1, value: string | string[]): Promise<TypeOf<TKind$1> | TypeOf<TKind$1>[]>;
|
|
58
|
+
/**
|
|
59
|
+
* An option.
|
|
60
|
+
*/
|
|
61
|
+
declare class Option<TKind$1 extends Kind, TRequired extends boolean = true, TList extends boolean = false> {
|
|
62
|
+
/**
|
|
63
|
+
* The kind of this option.
|
|
64
|
+
*/
|
|
65
|
+
$kind: TKind$1;
|
|
66
|
+
/**
|
|
67
|
+
* The aliases of this option.
|
|
68
|
+
*/
|
|
69
|
+
$names: string[];
|
|
70
|
+
/**
|
|
71
|
+
* The description of this option.
|
|
72
|
+
*/
|
|
73
|
+
$description: string | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* The default value of this option.
|
|
76
|
+
*/
|
|
77
|
+
$default: TypeOf<TKind$1> | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* If this option is required.
|
|
80
|
+
*/
|
|
81
|
+
$required: TRequired;
|
|
82
|
+
/**
|
|
83
|
+
* If this option is a list.
|
|
84
|
+
*/
|
|
85
|
+
$list: TList;
|
|
86
|
+
/**
|
|
87
|
+
* A separator if this option is a list.
|
|
88
|
+
*/
|
|
89
|
+
$separator: string | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a new option.
|
|
92
|
+
* @param kind The type of this option.
|
|
93
|
+
* @param names The names of this option.
|
|
94
|
+
*/
|
|
95
|
+
constructor(kind: TKind$1, names: string[]);
|
|
96
|
+
/**
|
|
97
|
+
* Makes this option a list.
|
|
98
|
+
* @returns this
|
|
99
|
+
*/
|
|
100
|
+
list(separator?: string): Option<TKind$1, TRequired, true>;
|
|
101
|
+
/**
|
|
102
|
+
* Makes this option required.
|
|
103
|
+
* @returns this
|
|
104
|
+
*/
|
|
105
|
+
required(): Option<TKind$1, true, TList>;
|
|
106
|
+
/**
|
|
107
|
+
* Makes this option optional.
|
|
108
|
+
* @returns this
|
|
109
|
+
*/
|
|
110
|
+
optional(): Option<TKind$1, false, TList>;
|
|
111
|
+
/**
|
|
112
|
+
* Sets a default value.
|
|
113
|
+
* @param value The default value.
|
|
114
|
+
* @returns this
|
|
115
|
+
*/
|
|
116
|
+
default(value: TypeOf<TKind$1>): this;
|
|
117
|
+
/**
|
|
118
|
+
* Sets a description.
|
|
119
|
+
* @param desc The description.
|
|
120
|
+
* @returns this
|
|
121
|
+
*/
|
|
122
|
+
description(desc: string): this;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* A positional argument.
|
|
126
|
+
*/
|
|
127
|
+
declare class Positional<TKind$1 extends Kind, TRequired extends boolean = true, TList extends boolean = false> {
|
|
128
|
+
/**
|
|
129
|
+
* The type of this argument.
|
|
130
|
+
*/
|
|
131
|
+
$kind: TKind$1;
|
|
132
|
+
/**
|
|
133
|
+
* The default value of this argument.
|
|
134
|
+
*/
|
|
135
|
+
$default: TypeOf<TKind$1> | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* The description of this argument.
|
|
138
|
+
*/
|
|
139
|
+
$description: string | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* If this argument is required.
|
|
142
|
+
*/
|
|
143
|
+
$required: TRequired;
|
|
144
|
+
/**
|
|
145
|
+
* If this argument is a list.
|
|
146
|
+
*/
|
|
147
|
+
$list: TList;
|
|
148
|
+
/**
|
|
149
|
+
* Creates a new positional argument.
|
|
150
|
+
* @param kind The positional argument.
|
|
151
|
+
*/
|
|
152
|
+
constructor(kind: TKind$1);
|
|
153
|
+
/**
|
|
154
|
+
* Makes this argument a list.
|
|
155
|
+
* @returns this
|
|
156
|
+
*/
|
|
157
|
+
list(): Positional<TKind$1, TRequired, true>;
|
|
158
|
+
/**
|
|
159
|
+
* Makes this argument required.
|
|
160
|
+
* @returns this
|
|
161
|
+
*/
|
|
162
|
+
required(): Positional<TKind$1, true, TList>;
|
|
163
|
+
/**
|
|
164
|
+
* Makes this argument optional.
|
|
165
|
+
* @returns this
|
|
166
|
+
*/
|
|
167
|
+
optional(): Positional<TKind$1, false, TList>;
|
|
168
|
+
/**
|
|
169
|
+
* Sets a default value.
|
|
170
|
+
* @param value The default value.
|
|
171
|
+
* @returns this
|
|
172
|
+
*/
|
|
173
|
+
default(value: TypeOf<TKind$1>): this;
|
|
174
|
+
/**
|
|
175
|
+
* Sets a description.
|
|
176
|
+
* @param desc The description.
|
|
177
|
+
* @returns this
|
|
178
|
+
*/
|
|
179
|
+
description(desc: string): this;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Creates a new option.
|
|
183
|
+
* @param kind The kind of option.
|
|
184
|
+
* @param names The names of the option.
|
|
185
|
+
* @returns A new option.
|
|
186
|
+
*/
|
|
187
|
+
declare function option<T extends Kind>(kind: T, ...names: string[]): Option<T>;
|
|
188
|
+
/**
|
|
189
|
+
* Creates a new positional argument.
|
|
190
|
+
* @param kind The kind of positional argument.
|
|
191
|
+
* @returns A new positional argument.
|
|
192
|
+
*/
|
|
193
|
+
declare function positional<T extends Kind>(kind: T): Positional<T>;
|
|
194
|
+
/**
|
|
195
|
+
* Creates a new positional argument.
|
|
196
|
+
* @param kind The kind of positional argument.
|
|
197
|
+
* @returns A new positional argument.
|
|
198
|
+
*/
|
|
199
|
+
declare function argument<T extends Kind>(kind: T): Positional<T>;
|
|
200
|
+
//#endregion
|
|
201
|
+
export { Kind as a, TypeOf as c, index_d_exports as d, option as f, Input as i, argument as l, InputValidationError as m, InferEntry as n, Option as o, positional as p, InferInput as r, Positional as s, BasicKind as t, convert as u };
|
|
202
|
+
//# sourceMappingURL=index-ClhbwSD8.d.mts.map
|