allow preset for string types
This commit is contained in:
		| @@ -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,11 +29,21 @@ export class InteractiveSource extends OptionSource { | ||||
|       || opt.type === 'path' | ||||
|       || opt.type === 'number' | ||||
|     ) { | ||||
|       value = await new Input ({ | ||||
|         message: this.get_message (opt), | ||||
|         default: opt.default | ||||
|       }) | ||||
|         .run (); | ||||
|       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' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user