This commit is contained in:
Timo Hocker
2020-05-05 11:56:36 +02:00
commit 80d0dc4a48
9 changed files with 3461 additions and 0 deletions

17
lib/.eslintrc.js Normal file
View File

@ -0,0 +1,17 @@
module.exports = {
env: {
commonjs: true,
es6: true,
node: true
},
extends: [
'@scode/eslint-config-ts'
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
parserOptions: {
ecmaVersion: 2018
}
}

28
lib/InteractiveOptions.ts Normal file
View File

@ -0,0 +1,28 @@
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;
}
}
}