diff --git a/src/utils/base-command.ts b/src/utils/base-command.ts index 3c9b45521..20cb69477 100644 --- a/src/utils/base-command.ts +++ b/src/utils/base-command.ts @@ -18,8 +18,8 @@ export function omitFlags(flagsToOmit: string[]): typeof BaseCommand.flags { export default abstract class BaseCommand extends Command { static flags = { help: flags.help({char: 'h'}), - input: flags.string({char: 'i', required: false, description: 'Input file to be converted'}), - output: flags.string({char: 'o', required: false}), + input: flags.string({char: 'i', required: true, description: 'Input file to be converted'}), + output: flags.string({char: 'o', required: true}), logLevel: flags.string({char: 'L', required: false, default: 'info', options: ['info', 'warn', 'debug', 'verbose']}), listAllCommands: flags.boolean({char: 'A', required: false, description: 'List all SAF CLI commands'}), } @@ -35,9 +35,15 @@ export default abstract class BaseCommand extends Command { const {flags} = this.parse(this.constructor as Input) this.parsedFlags = flags this.logger = createWinstonLogger(this.constructor.name, flags.logLevel as unknown as string) - - if (!flags.input) { - BaseCommand.inputFileData = await read(process.stdin, this.logger) + if (this.parsedFlags.input === '-') { + await new Promise((resolve, reject) => { + setTimeout(() => reject(new Error('STDIN Timeout')), 5000) + + read(process.stdin, this.logger).then(data => { + BaseCommand.inputFileData = data + resolve(data) + }) + }) } if (flags.listAllCommands) {