From 833119048605ab3cd4c95d21c73f2a22bd68ef9b Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 16 May 2018 10:29:57 -0400 Subject: [PATCH] quiet options --- src/program.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/program.ts b/src/program.ts index b4404e40b7..7672a67167 100644 --- a/src/program.ts +++ b/src/program.ts @@ -31,6 +31,7 @@ export class Program { .version(this.main.platformUtilsService.getApplicationVersion(), '-v, --version') .option('--pretty', 'Format stdout.') .option('--raw', 'Raw output instead a descriptive message.') + .option('--quiet', 'Do not write anything to stdout.') .option('--session ', 'Session key.'); program.on('option:pretty', () => { @@ -41,6 +42,10 @@ export class Program { process.env.BW_RAW = 'true'; }); + program.on('option:quiet', () => { + process.env.BW_QUIET = 'true'; + }); + program.on('option:session', (key) => { process.env.BW_SESSION = key; }); @@ -180,7 +185,9 @@ export class Program { private processResponse(response: Response) { if (!response.success) { - process.stdout.write(chalk.redBright(response.message)); + if (process.env.BW_QUIET !== 'true') { + process.stdout.write(chalk.redBright(response.message)); + } process.exit(1); return; } @@ -202,7 +209,7 @@ export class Program { out = this.getJson(response.data); } - if (out != null) { + if (out != null && process.env.BW_QUIET !== 'true') { process.stdout.write(out); } }