convoker 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +34 -0
- package/dist/chunks/__vite-browser-external-DQYBmsno.js +80 -0
- package/dist/chunks/color-CiruG_zQ.js +153 -0
- package/dist/chunks/error-Cj2qDfOl.js +95 -0
- package/dist/chunks/index-G2nVXKup.js +198 -0
- package/dist/chunks/input-COjWPD53.js +135 -0
- package/dist/chunks/standard-schema-Dn3nwAxU.js +12 -0
- package/dist/chunks/utils-DdmSEjLc.js +22 -0
- package/dist/color.d.ts +200 -0
- package/dist/color.js +49 -0
- package/dist/command.d.ts +527 -0
- package/dist/command.js +415 -0
- package/dist/error.d.ts +832 -0
- package/dist/error.js +10 -0
- package/dist/index.d.ts +1196 -0
- package/dist/index.js +13 -0
- package/dist/input.d.ts +248 -0
- package/dist/input.js +10 -0
- package/dist/prompt/raw.d.ts +32 -0
- package/dist/prompt/raw.js +9 -0
- package/dist/prompt.d.ts +258 -0
- package/dist/prompt.js +17 -0
- package/dist/raw.d.ts +38 -0
- package/package.json +70 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command as m, l as e } from "./command.js";
|
|
2
|
+
import { e as a } from "./chunks/error-Cj2qDfOl.js";
|
|
3
|
+
import { i as f } from "./chunks/input-COjWPD53.js";
|
|
4
|
+
import { a as s } from "./chunks/color-CiruG_zQ.js";
|
|
5
|
+
import { i } from "./chunks/index-G2nVXKup.js";
|
|
6
|
+
export {
|
|
7
|
+
m as Command,
|
|
8
|
+
s as color,
|
|
9
|
+
a as error,
|
|
10
|
+
f as i,
|
|
11
|
+
e as log,
|
|
12
|
+
i as prompt
|
|
13
|
+
};
|
package/dist/input.d.ts
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new positional argument.
|
|
3
|
+
* @param kind The kind of positional argument.
|
|
4
|
+
* @returns A new positional argument.
|
|
5
|
+
*/
|
|
6
|
+
export declare function argument<T extends Kind>(kind: T): Positional<T>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A basic input type.
|
|
10
|
+
*/
|
|
11
|
+
export declare type BasicKind = "boolean" | "string" | "number" | "bigint";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Converts a value from a Kind to a TypeScript type.
|
|
15
|
+
* @param kind The kind to convert to.
|
|
16
|
+
* @param value The value to convert.
|
|
17
|
+
* @returns The converted value.
|
|
18
|
+
*/
|
|
19
|
+
export declare function convert<TKind extends Kind>(kind: TKind, value: string): Promise<TypeOf<TKind>>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Infers a TypeScript type from an option or positional.
|
|
23
|
+
*/
|
|
24
|
+
export declare type InferEntry<T> = T extends {
|
|
25
|
+
$kind: infer TKind extends Kind;
|
|
26
|
+
$required: infer Required;
|
|
27
|
+
$list: infer List;
|
|
28
|
+
} ? List extends true ? Required extends true ? TypeOf<TKind>[] : TypeOf<TKind>[] | undefined : Required extends true ? TypeOf<TKind> : TypeOf<TKind> | undefined : never;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Infers TypeScript types from an input object.
|
|
32
|
+
*/
|
|
33
|
+
export declare type InferInput<T extends Input> = {
|
|
34
|
+
[K in keyof T]: InferEntry<T[K]>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* An input object.
|
|
39
|
+
*/
|
|
40
|
+
export declare interface Input {
|
|
41
|
+
[x: string]: Option_2<any, any, any> | Positional<any, any, any>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* An input type.
|
|
46
|
+
*/
|
|
47
|
+
export declare type Kind = BasicKind | StandardSchemaV1<any, any>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new option.
|
|
51
|
+
* @param kind The kind of option.
|
|
52
|
+
* @param names The names of the option.
|
|
53
|
+
* @returns A new option.
|
|
54
|
+
*/
|
|
55
|
+
export declare function option<T extends Kind>(kind: T, ...names: string[]): Option_2<T>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* An option.
|
|
59
|
+
*/
|
|
60
|
+
declare class Option_2<TKind extends Kind, TRequired extends boolean = true, TList extends boolean = false> {
|
|
61
|
+
/**
|
|
62
|
+
* The kind of this option.
|
|
63
|
+
*/
|
|
64
|
+
$kind: TKind;
|
|
65
|
+
/**
|
|
66
|
+
* The aliases of this option.
|
|
67
|
+
*/
|
|
68
|
+
$names: string[];
|
|
69
|
+
/**
|
|
70
|
+
* The description of this option.
|
|
71
|
+
*/
|
|
72
|
+
$description: string | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* The default value of this option.
|
|
75
|
+
*/
|
|
76
|
+
$default: TypeOf<TKind> | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* If this option is required.
|
|
79
|
+
*/
|
|
80
|
+
$required: TRequired;
|
|
81
|
+
/**
|
|
82
|
+
* If this option is a list.
|
|
83
|
+
*/
|
|
84
|
+
$list: TList;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a new option.
|
|
87
|
+
* @param kind The type of this option.
|
|
88
|
+
* @param names The names of this option.
|
|
89
|
+
*/
|
|
90
|
+
constructor(kind: TKind, names: string[]);
|
|
91
|
+
/**
|
|
92
|
+
* Makes this option a list.
|
|
93
|
+
* @returns this
|
|
94
|
+
*/
|
|
95
|
+
list(): Option_2<TKind, TRequired, true>;
|
|
96
|
+
/**
|
|
97
|
+
* Makes this option required.
|
|
98
|
+
* @returns this
|
|
99
|
+
*/
|
|
100
|
+
required(): Option_2<TKind, true, TList>;
|
|
101
|
+
/**
|
|
102
|
+
* Makes this option optional.
|
|
103
|
+
* @returns this
|
|
104
|
+
*/
|
|
105
|
+
optional(): Option_2<TKind, false, TList>;
|
|
106
|
+
/**
|
|
107
|
+
* Sets a default value.
|
|
108
|
+
* @param value The default value.
|
|
109
|
+
* @returns this
|
|
110
|
+
*/
|
|
111
|
+
default(value: TypeOf<TKind>): this;
|
|
112
|
+
/**
|
|
113
|
+
* Sets a description.
|
|
114
|
+
* @param desc The description.
|
|
115
|
+
* @returns this
|
|
116
|
+
*/
|
|
117
|
+
description(desc: string): this;
|
|
118
|
+
}
|
|
119
|
+
export { Option_2 as Option }
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* A positional argument.
|
|
123
|
+
*/
|
|
124
|
+
export declare class Positional<TKind extends Kind, TRequired extends boolean = true, TList extends boolean = false> {
|
|
125
|
+
/**
|
|
126
|
+
* The type of this argument.
|
|
127
|
+
*/
|
|
128
|
+
$kind: TKind;
|
|
129
|
+
/**
|
|
130
|
+
* The default value of this argument.
|
|
131
|
+
*/
|
|
132
|
+
$default: TypeOf<TKind> | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* The description of this argument.
|
|
135
|
+
*/
|
|
136
|
+
$description: string | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* If this argument is required.
|
|
139
|
+
*/
|
|
140
|
+
$required: TRequired;
|
|
141
|
+
/**
|
|
142
|
+
* If this argument is a list.
|
|
143
|
+
*/
|
|
144
|
+
$list: TList;
|
|
145
|
+
/**
|
|
146
|
+
* Creates a new positional argument.
|
|
147
|
+
* @param kind The positional argument.
|
|
148
|
+
*/
|
|
149
|
+
constructor(kind: TKind);
|
|
150
|
+
/**
|
|
151
|
+
* Makes this argument a list.
|
|
152
|
+
* @returns this
|
|
153
|
+
*/
|
|
154
|
+
list(): Positional<TKind, TRequired, true>;
|
|
155
|
+
/**
|
|
156
|
+
* Makes this argument required.
|
|
157
|
+
* @returns this
|
|
158
|
+
*/
|
|
159
|
+
required(): Positional<TKind, true, TList>;
|
|
160
|
+
/**
|
|
161
|
+
* Makes this argument optional.
|
|
162
|
+
* @returns this
|
|
163
|
+
*/
|
|
164
|
+
optional(): Positional<TKind, false, TList>;
|
|
165
|
+
/**
|
|
166
|
+
* Sets a default value.
|
|
167
|
+
* @param value The default value.
|
|
168
|
+
* @returns this
|
|
169
|
+
*/
|
|
170
|
+
default(value: TypeOf<TKind>): this;
|
|
171
|
+
/**
|
|
172
|
+
* Sets a description.
|
|
173
|
+
* @param desc The description.
|
|
174
|
+
* @returns this
|
|
175
|
+
*/
|
|
176
|
+
description(desc: string): this;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Creates a new positional argument.
|
|
181
|
+
* @param kind The kind of positional argument.
|
|
182
|
+
* @returns A new positional argument.
|
|
183
|
+
*/
|
|
184
|
+
export declare function positional<T extends Kind>(kind: T): Positional<T>;
|
|
185
|
+
|
|
186
|
+
/** The Standard Schema interface. */
|
|
187
|
+
declare interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
188
|
+
/** The Standard Schema properties. */
|
|
189
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare namespace StandardSchemaV1 {
|
|
193
|
+
/** The Standard Schema properties interface. */
|
|
194
|
+
interface Props<Input = unknown, Output = Input> {
|
|
195
|
+
/** The version number of the standard. */
|
|
196
|
+
readonly version: 1;
|
|
197
|
+
/** The vendor name of the schema library. */
|
|
198
|
+
readonly vendor: string;
|
|
199
|
+
/** Validates unknown input values. */
|
|
200
|
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
201
|
+
/** Inferred types associated with the schema. */
|
|
202
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
203
|
+
}
|
|
204
|
+
/** The result interface of the validate function. */
|
|
205
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
206
|
+
/** The result interface if validation succeeds. */
|
|
207
|
+
interface SuccessResult<Output> {
|
|
208
|
+
/** The typed output value. */
|
|
209
|
+
readonly value: Output;
|
|
210
|
+
/** The non-existent issues. */
|
|
211
|
+
readonly issues?: undefined;
|
|
212
|
+
}
|
|
213
|
+
/** The result interface if validation fails. */
|
|
214
|
+
interface FailureResult {
|
|
215
|
+
/** The issues of failed validation. */
|
|
216
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
217
|
+
}
|
|
218
|
+
/** The issue interface of the failure output. */
|
|
219
|
+
interface Issue {
|
|
220
|
+
/** The error message of the issue. */
|
|
221
|
+
readonly message: string;
|
|
222
|
+
/** The path of the issue, if any. */
|
|
223
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
224
|
+
}
|
|
225
|
+
/** The path segment interface of the issue. */
|
|
226
|
+
interface PathSegment {
|
|
227
|
+
/** The key representing a path segment. */
|
|
228
|
+
readonly key: PropertyKey;
|
|
229
|
+
}
|
|
230
|
+
/** The Standard Schema types interface. */
|
|
231
|
+
interface Types<Input = unknown, Output = Input> {
|
|
232
|
+
/** The input type of the schema. */
|
|
233
|
+
readonly input: Input;
|
|
234
|
+
/** The output type of the schema. */
|
|
235
|
+
readonly output: Output;
|
|
236
|
+
}
|
|
237
|
+
/** Infers the input type of a Standard Schema. */
|
|
238
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
239
|
+
/** Infers the output type of a Standard Schema. */
|
|
240
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Converts a Kind to a TypeScript type.
|
|
245
|
+
*/
|
|
246
|
+
export declare type TypeOf<T extends Kind> = T extends StandardSchemaV1<any, infer Out> ? Out : T extends "boolean" ? boolean : T extends "string" ? string : T extends "number" ? number : T extends "bigint" ? bigint : never;
|
|
247
|
+
|
|
248
|
+
export { }
|
package/dist/input.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a line from standard input.
|
|
3
|
+
* @param message The message.
|
|
4
|
+
* @param def Default value.
|
|
5
|
+
* @param opts Options for reading a line.
|
|
6
|
+
* @returns The line that was read.
|
|
7
|
+
*/
|
|
8
|
+
export declare function readLine(message?: string, def?: string, opts?: {
|
|
9
|
+
masked?: boolean;
|
|
10
|
+
maskChar?: string;
|
|
11
|
+
multiline?: boolean;
|
|
12
|
+
}): Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Reads a single key from stdin.
|
|
15
|
+
* @returns The key that was read.
|
|
16
|
+
*/
|
|
17
|
+
export declare function readKey(): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Clears `lines` amount of lines.
|
|
20
|
+
* @param lines Amount of lines to clear.
|
|
21
|
+
*/
|
|
22
|
+
export declare function clearLines(lines?: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Moves the cursor up `n` times.
|
|
25
|
+
* @param n The amount of steps to move.
|
|
26
|
+
*/
|
|
27
|
+
export declare function cursorUp(n?: number): void;
|
|
28
|
+
/**
|
|
29
|
+
* Moves the cursor down `n` times.
|
|
30
|
+
* @param n The amount of steps to move.
|
|
31
|
+
*/
|
|
32
|
+
export declare function cursorDown(n?: number): void;
|
package/dist/prompt.d.ts
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '../../../../../../../../../../src/standard-schema';
|
|
2
|
+
import { Theme } from '../../../../../../../../../../src/color';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base options for prompts.
|
|
6
|
+
*/
|
|
7
|
+
export declare interface BaseOpts<T> {
|
|
8
|
+
/**
|
|
9
|
+
* The message of the prompt.
|
|
10
|
+
*/
|
|
11
|
+
message: string;
|
|
12
|
+
/**
|
|
13
|
+
* An `AbortSignal` to cancel the prompt.
|
|
14
|
+
*/
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
/**
|
|
17
|
+
* The default value.
|
|
18
|
+
*/
|
|
19
|
+
default?: T;
|
|
20
|
+
/**
|
|
21
|
+
* The theme of the prompt.
|
|
22
|
+
*/
|
|
23
|
+
theme?: Theme;
|
|
24
|
+
/**
|
|
25
|
+
* A validator function, or a Standard Schema validator.
|
|
26
|
+
*/
|
|
27
|
+
validate?: StandardSchemaV1<any, T> | ((value: T) => boolean | T);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Clears `lines` amount of lines.
|
|
32
|
+
* @param lines Amount of lines to clear.
|
|
33
|
+
*/
|
|
34
|
+
declare function clearLines(lines?: number): void;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Prompts the user to confirm an action.
|
|
38
|
+
* @param opts Options for confirm input.
|
|
39
|
+
* @returns If the user picked Yes.
|
|
40
|
+
*/
|
|
41
|
+
declare function confirm_2(opts: ConfirmOpts): Promise<boolean>;
|
|
42
|
+
export { confirm_2 as confirm }
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Options for confirm input.
|
|
46
|
+
*/
|
|
47
|
+
export declare interface ConfirmOpts extends BaseOpts<boolean> {
|
|
48
|
+
/**
|
|
49
|
+
* What gets displayed for the Yes option.
|
|
50
|
+
*/
|
|
51
|
+
yesLabel?: string;
|
|
52
|
+
/**
|
|
53
|
+
* What gets displayed for the No option.
|
|
54
|
+
*/
|
|
55
|
+
noLabel?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Moves the cursor down `n` times.
|
|
60
|
+
* @param n The amount of steps to move.
|
|
61
|
+
*/
|
|
62
|
+
declare function cursorDown(n?: number): void;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Moves the cursor up `n` times.
|
|
66
|
+
* @param n The amount of steps to move.
|
|
67
|
+
*/
|
|
68
|
+
declare function cursorUp(n?: number): void;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Opens the system editor, or asks for input in the terminal as fallback.
|
|
72
|
+
* @param opts Options for opening the system editor.
|
|
73
|
+
* @returns The result of the system editor.
|
|
74
|
+
*/
|
|
75
|
+
export declare function editor(opts: EditorOpts): Promise<string>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Options for opening the system editor.
|
|
79
|
+
*/
|
|
80
|
+
export declare interface EditorOpts extends BaseOpts<string> {
|
|
81
|
+
/**
|
|
82
|
+
* The initial value.
|
|
83
|
+
*/
|
|
84
|
+
initial?: string;
|
|
85
|
+
/**
|
|
86
|
+
* The language of the value.
|
|
87
|
+
*/
|
|
88
|
+
language?: string;
|
|
89
|
+
/**
|
|
90
|
+
* If the input is required for continuing or not.
|
|
91
|
+
*/
|
|
92
|
+
required?: boolean;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Prompts the user to select multiple options.
|
|
97
|
+
* @param opts Options for select input.
|
|
98
|
+
* @returns The selected options.
|
|
99
|
+
*/
|
|
100
|
+
export declare function multiselect<T>(opts: SelectOpts<T>): Promise<T[]>;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Prompts the user for a password.
|
|
104
|
+
* @param opts Options for password input.
|
|
105
|
+
* @returns The password.
|
|
106
|
+
*/
|
|
107
|
+
export declare function password(opts: PasswordOpts): Promise<string>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Options for password input.
|
|
111
|
+
*/
|
|
112
|
+
export declare interface PasswordOpts extends TextOpts {
|
|
113
|
+
/**
|
|
114
|
+
* The mask for the password input.
|
|
115
|
+
*/
|
|
116
|
+
mask?: string;
|
|
117
|
+
/**
|
|
118
|
+
* If the user should be asked to confirm the password, by typing it again.
|
|
119
|
+
*/
|
|
120
|
+
confirm?: boolean;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
declare namespace raw {
|
|
124
|
+
export {
|
|
125
|
+
readLine,
|
|
126
|
+
readKey,
|
|
127
|
+
clearLines,
|
|
128
|
+
cursorUp,
|
|
129
|
+
cursorDown
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export { raw }
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Reads a single key from stdin.
|
|
136
|
+
* @returns The key that was read.
|
|
137
|
+
*/
|
|
138
|
+
declare function readKey(): Promise<string>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Reads a line from standard input.
|
|
142
|
+
* @param message The message.
|
|
143
|
+
* @param def Default value.
|
|
144
|
+
* @param opts Options for reading a line.
|
|
145
|
+
* @returns The line that was read.
|
|
146
|
+
*/
|
|
147
|
+
declare function readLine(message?: string, def?: string, opts?: {
|
|
148
|
+
masked?: boolean;
|
|
149
|
+
maskChar?: string;
|
|
150
|
+
multiline?: boolean;
|
|
151
|
+
}): Promise<string>;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Prompts the user to search through a list of options.
|
|
155
|
+
* @param opts Options for search input.
|
|
156
|
+
* @returns The selected option.
|
|
157
|
+
*/
|
|
158
|
+
export declare function search<T>(opts: SearchOpts<T>): Promise<T>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Options for search input.
|
|
162
|
+
*/
|
|
163
|
+
export declare interface SearchOpts<T> extends BaseOpts<T> {
|
|
164
|
+
/**
|
|
165
|
+
* Every option the user can search through.
|
|
166
|
+
*/
|
|
167
|
+
options: SelectOption<T>[];
|
|
168
|
+
/**
|
|
169
|
+
* Placeholder for the search input.
|
|
170
|
+
*/
|
|
171
|
+
placeholder?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Minimum length for a query string.
|
|
174
|
+
*/
|
|
175
|
+
minQueryLength?: number;
|
|
176
|
+
/**
|
|
177
|
+
* Filters a single option.
|
|
178
|
+
* @param query The search query.
|
|
179
|
+
* @param option The option to filter.
|
|
180
|
+
*/
|
|
181
|
+
filter?(query: string, option: SelectOption<T>): boolean;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Prompts the user to select a single option.
|
|
186
|
+
* @param opts Options for select input.
|
|
187
|
+
* @returns The selected option's value.
|
|
188
|
+
*/
|
|
189
|
+
export declare function select<T>(opts: SelectOpts<T>): Promise<T>;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* An option for select input.
|
|
193
|
+
*/
|
|
194
|
+
export declare interface SelectOption<T> {
|
|
195
|
+
/**
|
|
196
|
+
* The label (what gets displayed) of the select option.
|
|
197
|
+
*/
|
|
198
|
+
label: string;
|
|
199
|
+
/**
|
|
200
|
+
* The value (what gets returned) of the select option.
|
|
201
|
+
*/
|
|
202
|
+
value: T;
|
|
203
|
+
/**
|
|
204
|
+
* A description of the option.
|
|
205
|
+
*/
|
|
206
|
+
hint?: string;
|
|
207
|
+
/**
|
|
208
|
+
* If this option is disabled.
|
|
209
|
+
*/
|
|
210
|
+
disabled?: boolean;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Options for select input.
|
|
215
|
+
*/
|
|
216
|
+
export declare interface SelectOpts<T> extends BaseOpts<T> {
|
|
217
|
+
/**
|
|
218
|
+
* Every option the user can pick from.
|
|
219
|
+
*/
|
|
220
|
+
options: SelectOption<T>[];
|
|
221
|
+
/**
|
|
222
|
+
* The initial option selected.
|
|
223
|
+
*/
|
|
224
|
+
initialIndex?: number;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Sets the theme of the prompts.
|
|
229
|
+
* @param t The new theme.
|
|
230
|
+
*/
|
|
231
|
+
export declare function setTheme(t: Theme): void;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Prompts the user for text input.
|
|
235
|
+
* @param opts Options for text input.
|
|
236
|
+
* @returns The text the user typed in, or the default.
|
|
237
|
+
*/
|
|
238
|
+
export declare function text(opts: TextOpts): Promise<string>;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Options for text input.
|
|
242
|
+
*/
|
|
243
|
+
export declare interface TextOpts extends BaseOpts<string> {
|
|
244
|
+
/**
|
|
245
|
+
* A placeholder, displayed when the user hasn't typed anything yet.
|
|
246
|
+
*/
|
|
247
|
+
placeholder?: string;
|
|
248
|
+
/**
|
|
249
|
+
* Minimum length of the input.
|
|
250
|
+
*/
|
|
251
|
+
minLength?: number;
|
|
252
|
+
/**
|
|
253
|
+
* Maximum length of the input.
|
|
254
|
+
*/
|
|
255
|
+
maxLength?: number;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export { }
|
package/dist/prompt.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "./chunks/color-CiruG_zQ.js";
|
|
2
|
+
import "./chunks/standard-schema-Dn3nwAxU.js";
|
|
3
|
+
import "./chunks/error-Cj2qDfOl.js";
|
|
4
|
+
import "./chunks/utils-DdmSEjLc.js";
|
|
5
|
+
import { d as m } from "./chunks/__vite-browser-external-DQYBmsno.js";
|
|
6
|
+
import { c as i, e as c, m as d, p as f, b as l, a as x, s as h, t as w } from "./chunks/index-G2nVXKup.js";
|
|
7
|
+
export {
|
|
8
|
+
i as confirm,
|
|
9
|
+
c as editor,
|
|
10
|
+
d as multiselect,
|
|
11
|
+
f as password,
|
|
12
|
+
m as raw,
|
|
13
|
+
l as search,
|
|
14
|
+
x as select,
|
|
15
|
+
h as setTheme,
|
|
16
|
+
w as text
|
|
17
|
+
};
|
package/dist/raw.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clears `lines` amount of lines.
|
|
3
|
+
* @param lines Amount of lines to clear.
|
|
4
|
+
*/
|
|
5
|
+
export declare function clearLines(lines?: number): void;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Moves the cursor down `n` times.
|
|
9
|
+
* @param n The amount of steps to move.
|
|
10
|
+
*/
|
|
11
|
+
export declare function cursorDown(n?: number): void;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Moves the cursor up `n` times.
|
|
15
|
+
* @param n The amount of steps to move.
|
|
16
|
+
*/
|
|
17
|
+
export declare function cursorUp(n?: number): void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Reads a single key from stdin.
|
|
21
|
+
* @returns The key that was read.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readKey(): Promise<string>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Reads a line from standard input.
|
|
27
|
+
* @param message The message.
|
|
28
|
+
* @param def Default value.
|
|
29
|
+
* @param opts Options for reading a line.
|
|
30
|
+
* @returns The line that was read.
|
|
31
|
+
*/
|
|
32
|
+
export declare function readLine(message?: string, def?: string, opts?: {
|
|
33
|
+
masked?: boolean;
|
|
34
|
+
maskChar?: string;
|
|
35
|
+
multiline?: boolean;
|
|
36
|
+
}): Promise<string>;
|
|
37
|
+
|
|
38
|
+
export { }
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "convoker",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A simple, type safe CLI framework for TypeScript.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./command": {
|
|
13
|
+
"types": "./dist/command.d.ts",
|
|
14
|
+
"default": "./dist/command.js"
|
|
15
|
+
},
|
|
16
|
+
"./input": {
|
|
17
|
+
"types": "./dist/types.d.ts",
|
|
18
|
+
"default": "./dist/input.js"
|
|
19
|
+
},
|
|
20
|
+
"./color": {
|
|
21
|
+
"types": "./dist/color.d.ts",
|
|
22
|
+
"default": "./dist/color.js"
|
|
23
|
+
},
|
|
24
|
+
"./prompt": {
|
|
25
|
+
"types": "./dist/prompt.js",
|
|
26
|
+
"default": "./dist/prompt/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./prompt/raw": {
|
|
29
|
+
"types": "./dist/prompt/raw.d.ts",
|
|
30
|
+
"default": "./dist/prompt/raw.js"
|
|
31
|
+
},
|
|
32
|
+
"./error": {
|
|
33
|
+
"types": "./dist/error.d.ts",
|
|
34
|
+
"default": "./dist/error.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"type": "module",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"keywords": [
|
|
42
|
+
"cli",
|
|
43
|
+
"command",
|
|
44
|
+
"args",
|
|
45
|
+
"argv",
|
|
46
|
+
"option"
|
|
47
|
+
],
|
|
48
|
+
"author": "trailfrost",
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@eslint/js": "^9.36.0",
|
|
52
|
+
"eslint": "^9.36.0",
|
|
53
|
+
"globals": "^16.4.0",
|
|
54
|
+
"prettier": "^3.6.2",
|
|
55
|
+
"typescript": "^5.9.2",
|
|
56
|
+
"typescript-eslint": "^8.45.0",
|
|
57
|
+
"valibot": "^1.1.0",
|
|
58
|
+
"vite": "^7.1.12",
|
|
59
|
+
"vite-plugin-dts": "^4.5.4",
|
|
60
|
+
"vitest": "^3.2.4"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"test": "vitest tests",
|
|
64
|
+
"build": "tsc -b && vite build",
|
|
65
|
+
"format": "prettier --check .",
|
|
66
|
+
"format!": "prettier --write .",
|
|
67
|
+
"lint": "eslint .",
|
|
68
|
+
"lint!": "eslint --fix ."
|
|
69
|
+
}
|
|
70
|
+
}
|