This commit is contained in:
Timo Hocker
2020-05-05 12:17:48 +02:00
parent 80d0dc4a48
commit 0e12cd0fb5
2 changed files with 32 additions and 4 deletions

View File

@ -11,12 +11,22 @@ interface Option {
type: OptionType;
required?: boolean;
default: unknown;
alias: string;
env: string;
}
interface OptionProcess extends Option {
filled: boolean;
}
export class InteractiveOptions extends Persistent {
protected options: Array<OptionProcess>;
public constructor (options: Array<Option>) {
super ();
for (const option of options) {
this.options = options
.map ((v) => ({ filled: false, ...v } as OptionProcess));
for (const option of this.options) {
if (typeof option.default !== option.type) {
throw new Error (
`default does not match option type on ${option.name}`
@ -25,4 +35,22 @@ export class InteractiveOptions extends Persistent {
this.properties[option.name] = option.type;
}
}
public async parse (): Promise<void> {
this.get_env_options ();
this.get_args_options ();
await this.get_interactive_options ();
}
private get_env_options (): void {
}
private get_args_options (): void {
}
private async get_interactive_options (): Promise<void> {
}
}