inquirerer 0.11.0 → 0.12.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/esm/prompt.js +17 -10
- package/package.json +2 -2
- package/prompt.d.ts +2 -1
- package/prompt.js +17 -10
package/esm/prompt.js
CHANGED
|
@@ -184,7 +184,7 @@ export class Inquirerer {
|
|
|
184
184
|
if (this.noTty || !this.rl)
|
|
185
185
|
return question.default ?? []; // Return default if non-interactive
|
|
186
186
|
this.keypress.resume();
|
|
187
|
-
const options =
|
|
187
|
+
const options = this.sanitizeOptions(question);
|
|
188
188
|
let input = ''; // Search input
|
|
189
189
|
let filteredOptions = options;
|
|
190
190
|
let selectedIndex = 0;
|
|
@@ -281,19 +281,11 @@ export class Inquirerer {
|
|
|
281
281
|
});
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
|
-
getOptionValue(option) {
|
|
285
|
-
if (typeof option === 'string') {
|
|
286
|
-
return { name: option, value: option };
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
return { name: option.name, value: option.value };
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
284
|
async autocomplete(question, ctx) {
|
|
293
285
|
if (this.noTty || !this.rl)
|
|
294
286
|
return question.default ?? false; // Return default if non-interactive
|
|
295
287
|
this.keypress.resume();
|
|
296
|
-
const options =
|
|
288
|
+
const options = this.sanitizeOptions(question);
|
|
297
289
|
let input = '';
|
|
298
290
|
let filteredOptions = options;
|
|
299
291
|
let selectedIndex = 0;
|
|
@@ -373,6 +365,21 @@ export class Inquirerer {
|
|
|
373
365
|
});
|
|
374
366
|
});
|
|
375
367
|
}
|
|
368
|
+
getOptionValue(option) {
|
|
369
|
+
if (typeof option === 'string') {
|
|
370
|
+
return { name: option, value: option };
|
|
371
|
+
}
|
|
372
|
+
else if (typeof option === 'object' && 'name' in option) {
|
|
373
|
+
return { name: option.name, value: option.value };
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
return undefined;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
sanitizeOptions(question) {
|
|
380
|
+
const options = (question.options ?? []).map(option => this.getOptionValue(option));
|
|
381
|
+
return options.filter(Boolean);
|
|
382
|
+
}
|
|
376
383
|
filterOptions(options, input) {
|
|
377
384
|
input = input.toLowerCase(); // Normalize input for case-insensitive comparison
|
|
378
385
|
// Fuzzy matching: Check if all characters of the input can be found in the option name in order
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inquirerer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
5
|
"description": "inquirerer",
|
|
6
6
|
"main": "index.js",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"minimist": "^1.2.8"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [],
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "181e8fae97cb71bee0678a110d0b81d06f618f02"
|
|
39
39
|
}
|
package/prompt.d.ts
CHANGED
|
@@ -30,8 +30,9 @@ export declare class Inquirerer {
|
|
|
30
30
|
confirm(question: ConfirmQuestion, ctx: PromptContext): Promise<boolean>;
|
|
31
31
|
text(question: TextQuestion, ctx: PromptContext): Promise<string | null>;
|
|
32
32
|
checkbox(question: CheckboxQuestion, ctx: PromptContext): Promise<OptionValue[]>;
|
|
33
|
-
private getOptionValue;
|
|
34
33
|
autocomplete(question: AutocompleteQuestion, ctx: PromptContext): Promise<any>;
|
|
34
|
+
private getOptionValue;
|
|
35
|
+
private sanitizeOptions;
|
|
35
36
|
filterOptions(options: OptionValue[], input: string): OptionValue[];
|
|
36
37
|
getMaxLines(question: {
|
|
37
38
|
maxDisplayLines?: number;
|
package/prompt.js
CHANGED
|
@@ -190,7 +190,7 @@ class Inquirerer {
|
|
|
190
190
|
if (this.noTty || !this.rl)
|
|
191
191
|
return question.default ?? []; // Return default if non-interactive
|
|
192
192
|
this.keypress.resume();
|
|
193
|
-
const options =
|
|
193
|
+
const options = this.sanitizeOptions(question);
|
|
194
194
|
let input = ''; // Search input
|
|
195
195
|
let filteredOptions = options;
|
|
196
196
|
let selectedIndex = 0;
|
|
@@ -287,19 +287,11 @@ class Inquirerer {
|
|
|
287
287
|
});
|
|
288
288
|
});
|
|
289
289
|
}
|
|
290
|
-
getOptionValue(option) {
|
|
291
|
-
if (typeof option === 'string') {
|
|
292
|
-
return { name: option, value: option };
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
return { name: option.name, value: option.value };
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
290
|
async autocomplete(question, ctx) {
|
|
299
291
|
if (this.noTty || !this.rl)
|
|
300
292
|
return question.default ?? false; // Return default if non-interactive
|
|
301
293
|
this.keypress.resume();
|
|
302
|
-
const options =
|
|
294
|
+
const options = this.sanitizeOptions(question);
|
|
303
295
|
let input = '';
|
|
304
296
|
let filteredOptions = options;
|
|
305
297
|
let selectedIndex = 0;
|
|
@@ -379,6 +371,21 @@ class Inquirerer {
|
|
|
379
371
|
});
|
|
380
372
|
});
|
|
381
373
|
}
|
|
374
|
+
getOptionValue(option) {
|
|
375
|
+
if (typeof option === 'string') {
|
|
376
|
+
return { name: option, value: option };
|
|
377
|
+
}
|
|
378
|
+
else if (typeof option === 'object' && 'name' in option) {
|
|
379
|
+
return { name: option.name, value: option.value };
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
return undefined;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
sanitizeOptions(question) {
|
|
386
|
+
const options = (question.options ?? []).map(option => this.getOptionValue(option));
|
|
387
|
+
return options.filter(Boolean);
|
|
388
|
+
}
|
|
382
389
|
filterOptions(options, input) {
|
|
383
390
|
input = input.toLowerCase(); // Normalize input for case-insensitive comparison
|
|
384
391
|
// Fuzzy matching: Check if all characters of the input can be found in the option name in order
|