init
This commit is contained in:
		
							
								
								
									
										17
									
								
								lib/.eslintrc.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								lib/.eslintrc.js
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										28
									
								
								lib/InteractiveOptions.ts
									
									
									
									
									
										Normal 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; | ||||
|     } | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user