console-app/lib/InteractiveOptions.ts
Timo Hocker 80d0dc4a48 init
2020-05-05 11:56:36 +02:00

29 lines
607 B
TypeScript

import { Persistent } from '@scode/modelling';
enum OptionType {
string = 'string',
number = 'number',
boolean = 'boolean'
}
interface Option {
name: string;
type: OptionType;
required?: boolean;
default: unknown;
}
export class InteractiveOptions extends Persistent {
public constructor (options: Array<Option>) {
super ();
for (const option of options) {
if (typeof option.default !== option.type) {
throw new Error (
`default does not match option type on ${option.name}`
);
}
this.properties[option.name] = option.type;
}
}
}