allow preset for string types
This commit is contained in:
parent
cee181caeb
commit
0307cb7916
@ -17,6 +17,7 @@ interface Option {
|
||||
env?: string;
|
||||
description?: string;
|
||||
message?: string;
|
||||
preset?: unknown[];
|
||||
}
|
||||
|
||||
interface OptionProcess extends Option {
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
/* eslint-disable no-console */
|
||||
/* eslint-disable no-process-exit */
|
||||
import { Confirm, Input, List } from 'enquirer';
|
||||
import { Confirm, Input, List, AutoComplete } from 'enquirer';
|
||||
import { OptionProcess, Option } from '../Option';
|
||||
import { OptionSource } from './OptionSource';
|
||||
|
||||
@ -29,12 +29,22 @@ export class InteractiveSource extends OptionSource {
|
||||
|| opt.type === 'path'
|
||||
|| opt.type === 'number'
|
||||
) {
|
||||
if (typeof opt.preset === 'undefined') {
|
||||
value = await new Input ({
|
||||
message: this.get_message (opt),
|
||||
default: opt.default
|
||||
})
|
||||
.run ();
|
||||
}
|
||||
else {
|
||||
value = await new AutoComplete ({
|
||||
message: this.get_message (opt),
|
||||
default: opt.default,
|
||||
choices: opt.preset
|
||||
})
|
||||
.run ();
|
||||
}
|
||||
}
|
||||
if (
|
||||
opt.type === 'boolean'
|
||||
) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user