@awsless/clui 0.0.1 → 0.0.3
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/index.cjs +38 -2
- package/dist/index.d.cts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +38 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -60,6 +60,8 @@ var info = "\xB7";
|
|
|
60
60
|
var prompts_exports = {};
|
|
61
61
|
__export(prompts_exports, {
|
|
62
62
|
confirm: () => confirm,
|
|
63
|
+
float: () => float,
|
|
64
|
+
integer: () => integer,
|
|
63
65
|
multiSelect: () => multiSelect,
|
|
64
66
|
password: () => password,
|
|
65
67
|
select: () => select,
|
|
@@ -93,6 +95,40 @@ var password = async (opts) => {
|
|
|
93
95
|
return (0, import_prompts2.password)({ mask: "*", ...opts });
|
|
94
96
|
}, opts);
|
|
95
97
|
};
|
|
98
|
+
var integer = async (opts) => {
|
|
99
|
+
const result = await text({
|
|
100
|
+
...opts,
|
|
101
|
+
defaultValue: opts.defaultValue?.toString(),
|
|
102
|
+
initialValue: opts.initialValue?.toString(),
|
|
103
|
+
validate(value) {
|
|
104
|
+
if (isNaN(Number(value)) || isNaN(parseInt(value, 10)) || value.includes(".")) {
|
|
105
|
+
return "Invalid integer";
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
if (typeof result === "string") {
|
|
111
|
+
return parseInt(result, 10);
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
};
|
|
115
|
+
var float = async (opts) => {
|
|
116
|
+
const result = await text({
|
|
117
|
+
...opts,
|
|
118
|
+
defaultValue: opts.defaultValue?.toString(),
|
|
119
|
+
initialValue: opts.initialValue?.toString(),
|
|
120
|
+
validate(value) {
|
|
121
|
+
if (isNaN(Number(value)) || isNaN(parseFloat(value))) {
|
|
122
|
+
return "Invalid float";
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
if (typeof result === "string") {
|
|
128
|
+
return parseFloat(result);
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
};
|
|
96
132
|
var confirm = async (opts) => {
|
|
97
133
|
return wrapPrompt(() => {
|
|
98
134
|
return (0, import_prompts2.confirm)(opts);
|
|
@@ -162,10 +198,10 @@ var color = import_chalk.default;
|
|
|
162
198
|
|
|
163
199
|
// src/logs.ts
|
|
164
200
|
var endMargin = 1;
|
|
165
|
-
var intro = (title) => {
|
|
201
|
+
var intro = (title = "") => {
|
|
166
202
|
(0, import_prompts3.intro)(subString(title, process.stdout.columns - 8 - endMargin));
|
|
167
203
|
};
|
|
168
|
-
var outro = (title) => {
|
|
204
|
+
var outro = (title = "") => {
|
|
169
205
|
(0, import_prompts3.outro)(subString(title, process.stdout.columns - 8 - endMargin));
|
|
170
206
|
};
|
|
171
207
|
var note = (title, message2) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -23,21 +23,31 @@ type WrapPromptOptions<T extends boolean | undefined = boolean> = {
|
|
|
23
23
|
|
|
24
24
|
declare const text: <T extends boolean | undefined = undefined>(opts: TextOptions & WrapPromptOptions<T>) => Promise<T extends false ? string | symbol : string>;
|
|
25
25
|
declare const password: <T extends boolean | undefined = undefined>(opts: PasswordOptions & WrapPromptOptions<T>) => Promise<T extends false ? string | symbol : string>;
|
|
26
|
+
type NumberOptions = {
|
|
27
|
+
message: string;
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
defaultValue?: number;
|
|
30
|
+
initialValue?: number;
|
|
31
|
+
};
|
|
32
|
+
declare const integer: <T extends boolean | undefined = undefined>(opts: NumberOptions & WrapPromptOptions<T>) => Promise<number | (T extends false ? string | symbol : string)>;
|
|
33
|
+
declare const float: <T extends boolean | undefined = undefined>(opts: NumberOptions & WrapPromptOptions<T>) => Promise<number | (T extends false ? string | symbol : string)>;
|
|
26
34
|
declare const confirm: <T extends boolean | undefined = undefined>(opts: ConfirmOptions & WrapPromptOptions<T>) => Promise<T extends false ? boolean | symbol : boolean>;
|
|
27
35
|
declare const select: <Value, T extends boolean | undefined = undefined>(opts: SelectOptions<Value> & WrapPromptOptions<T>) => Promise<T extends false ? symbol | Value : Exclude<Value, symbol>>;
|
|
28
36
|
declare const multiSelect: <Value, T extends boolean | undefined = undefined>(opts: MultiSelectOptions<Value> & WrapPromptOptions<T>) => Promise<T extends false ? symbol | Value[] : Value[]>;
|
|
29
37
|
|
|
30
38
|
declare const prompts_confirm: typeof confirm;
|
|
39
|
+
declare const prompts_float: typeof float;
|
|
40
|
+
declare const prompts_integer: typeof integer;
|
|
31
41
|
declare const prompts_multiSelect: typeof multiSelect;
|
|
32
42
|
declare const prompts_password: typeof password;
|
|
33
43
|
declare const prompts_select: typeof select;
|
|
34
44
|
declare const prompts_text: typeof text;
|
|
35
45
|
declare namespace prompts {
|
|
36
|
-
export { prompts_confirm as confirm, prompts_multiSelect as multiSelect, prompts_password as password, prompts_select as select, prompts_text as text };
|
|
46
|
+
export { prompts_confirm as confirm, prompts_float as float, prompts_integer as integer, prompts_multiSelect as multiSelect, prompts_password as password, prompts_select as select, prompts_text as text };
|
|
37
47
|
}
|
|
38
48
|
|
|
39
|
-
declare const intro: (title
|
|
40
|
-
declare const outro: (title
|
|
49
|
+
declare const intro: (title?: string) => void;
|
|
50
|
+
declare const outro: (title?: string) => void;
|
|
41
51
|
declare const note: (title: string, message: string) => void;
|
|
42
52
|
declare const message: (message: string, symbol?: string) => void;
|
|
43
53
|
declare const error: (message: string) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,21 +23,31 @@ type WrapPromptOptions<T extends boolean | undefined = boolean> = {
|
|
|
23
23
|
|
|
24
24
|
declare const text: <T extends boolean | undefined = undefined>(opts: TextOptions & WrapPromptOptions<T>) => Promise<T extends false ? string | symbol : string>;
|
|
25
25
|
declare const password: <T extends boolean | undefined = undefined>(opts: PasswordOptions & WrapPromptOptions<T>) => Promise<T extends false ? string | symbol : string>;
|
|
26
|
+
type NumberOptions = {
|
|
27
|
+
message: string;
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
defaultValue?: number;
|
|
30
|
+
initialValue?: number;
|
|
31
|
+
};
|
|
32
|
+
declare const integer: <T extends boolean | undefined = undefined>(opts: NumberOptions & WrapPromptOptions<T>) => Promise<number | (T extends false ? string | symbol : string)>;
|
|
33
|
+
declare const float: <T extends boolean | undefined = undefined>(opts: NumberOptions & WrapPromptOptions<T>) => Promise<number | (T extends false ? string | symbol : string)>;
|
|
26
34
|
declare const confirm: <T extends boolean | undefined = undefined>(opts: ConfirmOptions & WrapPromptOptions<T>) => Promise<T extends false ? boolean | symbol : boolean>;
|
|
27
35
|
declare const select: <Value, T extends boolean | undefined = undefined>(opts: SelectOptions<Value> & WrapPromptOptions<T>) => Promise<T extends false ? symbol | Value : Exclude<Value, symbol>>;
|
|
28
36
|
declare const multiSelect: <Value, T extends boolean | undefined = undefined>(opts: MultiSelectOptions<Value> & WrapPromptOptions<T>) => Promise<T extends false ? symbol | Value[] : Value[]>;
|
|
29
37
|
|
|
30
38
|
declare const prompts_confirm: typeof confirm;
|
|
39
|
+
declare const prompts_float: typeof float;
|
|
40
|
+
declare const prompts_integer: typeof integer;
|
|
31
41
|
declare const prompts_multiSelect: typeof multiSelect;
|
|
32
42
|
declare const prompts_password: typeof password;
|
|
33
43
|
declare const prompts_select: typeof select;
|
|
34
44
|
declare const prompts_text: typeof text;
|
|
35
45
|
declare namespace prompts {
|
|
36
|
-
export { prompts_confirm as confirm, prompts_multiSelect as multiSelect, prompts_password as password, prompts_select as select, prompts_text as text };
|
|
46
|
+
export { prompts_confirm as confirm, prompts_float as float, prompts_integer as integer, prompts_multiSelect as multiSelect, prompts_password as password, prompts_select as select, prompts_text as text };
|
|
37
47
|
}
|
|
38
48
|
|
|
39
|
-
declare const intro: (title
|
|
40
|
-
declare const outro: (title
|
|
49
|
+
declare const intro: (title?: string) => void;
|
|
50
|
+
declare const outro: (title?: string) => void;
|
|
41
51
|
declare const note: (title: string, message: string) => void;
|
|
42
52
|
declare const message: (message: string, symbol?: string) => void;
|
|
43
53
|
declare const error: (message: string) => void;
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,8 @@ var info = "\xB7";
|
|
|
26
26
|
var prompts_exports = {};
|
|
27
27
|
__export(prompts_exports, {
|
|
28
28
|
confirm: () => confirm,
|
|
29
|
+
float: () => float,
|
|
30
|
+
integer: () => integer,
|
|
29
31
|
multiSelect: () => multiSelect,
|
|
30
32
|
password: () => password,
|
|
31
33
|
select: () => select,
|
|
@@ -65,6 +67,40 @@ var password = async (opts) => {
|
|
|
65
67
|
return p_password({ mask: "*", ...opts });
|
|
66
68
|
}, opts);
|
|
67
69
|
};
|
|
70
|
+
var integer = async (opts) => {
|
|
71
|
+
const result = await text({
|
|
72
|
+
...opts,
|
|
73
|
+
defaultValue: opts.defaultValue?.toString(),
|
|
74
|
+
initialValue: opts.initialValue?.toString(),
|
|
75
|
+
validate(value) {
|
|
76
|
+
if (isNaN(Number(value)) || isNaN(parseInt(value, 10)) || value.includes(".")) {
|
|
77
|
+
return "Invalid integer";
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
if (typeof result === "string") {
|
|
83
|
+
return parseInt(result, 10);
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
};
|
|
87
|
+
var float = async (opts) => {
|
|
88
|
+
const result = await text({
|
|
89
|
+
...opts,
|
|
90
|
+
defaultValue: opts.defaultValue?.toString(),
|
|
91
|
+
initialValue: opts.initialValue?.toString(),
|
|
92
|
+
validate(value) {
|
|
93
|
+
if (isNaN(Number(value)) || isNaN(parseFloat(value))) {
|
|
94
|
+
return "Invalid float";
|
|
95
|
+
}
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
if (typeof result === "string") {
|
|
100
|
+
return parseFloat(result);
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
};
|
|
68
104
|
var confirm = async (opts) => {
|
|
69
105
|
return wrapPrompt(() => {
|
|
70
106
|
return p_confirm(opts);
|
|
@@ -134,10 +170,10 @@ var color = chalk;
|
|
|
134
170
|
|
|
135
171
|
// src/logs.ts
|
|
136
172
|
var endMargin = 1;
|
|
137
|
-
var intro = (title) => {
|
|
173
|
+
var intro = (title = "") => {
|
|
138
174
|
p_intro(subString(title, process.stdout.columns - 8 - endMargin));
|
|
139
175
|
};
|
|
140
|
-
var outro = (title) => {
|
|
176
|
+
var outro = (title = "") => {
|
|
141
177
|
p_outro(subString(title, process.stdout.columns - 8 - endMargin));
|
|
142
178
|
};
|
|
143
179
|
var note = (title, message2) => {
|