From a09816dd6e5b1c7f09d90d21797d7cbcd0fcff88 Mon Sep 17 00:00:00 2001 From: Timo Hocker Date: Thu, 7 May 2020 12:19:19 +0200 Subject: [PATCH] fixes --- lib/InteractiveOptions.ts | 70 ++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git a/lib/InteractiveOptions.ts b/lib/InteractiveOptions.ts index f48b6ac..c55b5e2 100644 --- a/lib/InteractiveOptions.ts +++ b/lib/InteractiveOptions.ts @@ -1,3 +1,5 @@ +/* eslint-disable no-process-exit */ +/* eslint-disable no-console */ /* * Copyright (C) Sapphirecode - All Rights Reserved * This file is part of console-app which is released under MIT. @@ -38,24 +40,40 @@ interface OptionProcess extends Option { value?: unknown; } +function get_string_type (type: OptionType): 'string'|'number'|'boolean' { + if ([ + 'string', + 'number', + 'boolean' + ].includes (type)) + return type as ('string'|'number'|'boolean'); + if ([ + 'file', + 'folder', + 'path' + ].includes (type)) + return 'string'; + throw new Error (`unknown option type ${type}`); +} + export class InteractiveOptions extends Persistent { protected options: Array; + protected quiet = false; public constructor (options: Array