/* * Copyright (C) Sapphirecode - All Rights Reserved * This file is part of console-app which is released under MIT. * See file 'LICENSE' for full license details. * Created by Timo Hocker , October 2020 */ import { OptionValue, Option } from '../../Option'; export abstract class InteractiveSubSource { protected val: OptionValue; protected opt: Option; protected abstract condition():boolean; protected abstract async run():Promise; public constructor ( val:OptionValue, opt:Option ) { this.val = val; this.opt = opt; } public async parse ():Promise { if (this.condition ()) { await this.run (); return true; } return false; } protected get_message (): string { return typeof this.opt.message === 'undefined' ? `input ${this.opt.name}` : this.opt.message; } }