29 lines
767 B
TypeScript
29 lines
767 B
TypeScript
import { AutoComplete } from 'enquirer';
|
|
import { StringOptionConfig } from '../../SubConfigs';
|
|
import { InteractiveSubSource } from './InteractiveSubSource';
|
|
|
|
export class PresetSubSource extends InteractiveSubSource {
|
|
protected condition ():boolean {
|
|
return [
|
|
'string',
|
|
'file',
|
|
'folder',
|
|
'path'
|
|
].includes (this.val.type_validation.option_type)
|
|
&& typeof (this.opt as StringOptionConfig).preset !== 'undefined';
|
|
}
|
|
|
|
protected async run ():Promise<void> {
|
|
await this.val.assign_arg (
|
|
this.opt,
|
|
await new AutoComplete ({
|
|
message: this.get_message (),
|
|
default: this.opt.default,
|
|
choices: (this.opt as StringOptionConfig).preset,
|
|
limit: 10
|
|
})
|
|
.run ()
|
|
);
|
|
}
|
|
}
|