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