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> {
}
}

View File

@ -254,9 +254,9 @@
eslint-plugin-sort-requires-by-path "^1.0.2"
"@scode/modelling@^1.0.24":
version "1.0.25"
resolved "https://npm.scode.ovh/@scode%2fmodelling/-/modelling-1.0.25.tgz#d9b7dd4c13bdaffab3594601aa09b14757461900"
integrity sha512-6Li0G8AhDHMk/eZgFsARPncpdczcr25KRY32nGllIxnfmeaBvnVfbKGJWGFi7+D7WvBJh1UHcb7tWeU+zEro+Q==
version "1.0.26"
resolved "https://npm.scode.ovh/@scode%2fmodelling/-/modelling-1.0.26.tgz#e976a98762cb3c1b66af7d65616a50022230e5b1"
integrity sha512-Pk6NXQ7HurAlCaLChvX8ycgbWZG31I2UwnKEyevvxYPS6WvNqFpEhxve1sRas1caQrVq0b626nyVjChviPZT+Q==
"@sindresorhus/is@^0.14.0":
version "0.14.0"