From af10b816888bc83cca4a8abe5b182ee1481a64b5 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Fri, 16 Aug 2024 13:19:43 -0600 Subject: [PATCH] feat: different approach --- src/exported.ts | 1 - src/sfCommand.ts | 10 ++++++++++ src/ux/multiStageOutput.ts | 18 ------------------ 3 files changed, 10 insertions(+), 19 deletions(-) delete mode 100644 src/ux/multiStageOutput.ts diff --git a/src/exported.ts b/src/exported.ts index cf085dda5..b2343008c 100644 --- a/src/exported.ts +++ b/src/exported.ts @@ -8,7 +8,6 @@ export { toHelpSection, parseVarArgs } from './util.js'; export { Progress } from './ux/progress.js'; export { Spinner } from './ux/spinner.js'; -export { MultiStageOutput } from './ux/multiStageOutput.js'; export { Ux } from './ux/ux.js'; export { StandardColors } from './ux/standardColors.js'; diff --git a/src/sfCommand.ts b/src/sfCommand.ts index b57056eec..f87e73542 100644 --- a/src/sfCommand.ts +++ b/src/sfCommand.ts @@ -17,6 +17,7 @@ import { StructuredMessage, } from '@salesforce/core'; import type { AnyJson } from '@salesforce/ts-types'; +import { MultiStageOutput, MultiStageOutputOptions } from '@oclif/multi-stage-output'; import { Progress } from './ux/progress.js'; import { Spinner } from './ux/spinner.js'; import { Ux } from './ux/ux.js'; @@ -314,6 +315,15 @@ export abstract class SfCommand extends Command { return confirm({ message, ms, defaultAnswer }); } + public initStager>(options: MultiStageOutputOptions): MultiStageOutput { + const ms = new MultiStageOutput(options); + if (this.jsonEnabled()) { + ms.stop(); + } + + return ms; + } + public async _run(): Promise { ['SIGINT', 'SIGTERM', 'SIGBREAK', 'SIGHUP'].map((listener) => { process.on(listener, () => { diff --git a/src/ux/multiStageOutput.ts b/src/ux/multiStageOutput.ts deleted file mode 100644 index 85141a2f8..000000000 --- a/src/ux/multiStageOutput.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2024, salesforce.com, inc. - * All rights reserved. - * Licensed under the BSD 3-Clause license. - * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause - */ - -import { MultiStageOutput as OclifMultiStageOutput, MultiStageOutputOptions } from '@oclif/multi-stage-output'; - -export class MultiStageOutput> extends OclifMultiStageOutput { - public constructor(opts: MultiStageOutputOptions & { outputEnabled: boolean }) { - const { outputEnabled, ...rest } = opts; - super(rest); - if (!outputEnabled) { - this.stop(); - } - } -}