Skip to content

Commit 39ac67e

Browse files
committed
feat: add MultiStageOutput
1 parent 83f6799 commit 39ac67e

File tree

5 files changed

+276
-34
lines changed

5 files changed

+276
-34
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"@inquirer/confirm": "^3.1.22",
4848
"@inquirer/password": "^2.1.22",
4949
"@oclif/core": "^4.0.15",
50+
"@oclif/multi-stage-output": "^0.2.1",
5051
"@salesforce/core": "^8.2.7",
5152
"@salesforce/kit": "^3.2.1",
5253
"@salesforce/ts-types": "^2.0.12",

src/exported.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
export { toHelpSection, parseVarArgs } from './util.js';
99
export { Progress } from './ux/progress.js';
1010
export { Spinner } from './ux/spinner.js';
11+
export { MultiStageOutput } from './ux/multiStageOutput.js';
1112
export { Ux } from './ux/ux.js';
1213
export { StandardColors } from './ux/standardColors.js';
1314

src/ux/multiStageOutput.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2024, salesforce.com, inc.
3+
* All rights reserved.
4+
* Licensed under the BSD 3-Clause license.
5+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
8+
import { MultiStageOutput as OclifMultiStageOutput, MultiStageOutputOptions } from '@oclif/multi-stage-output';
9+
10+
/**
11+
* This class is a light wrapper around MultiStageOutput that allows us to
12+
* automatically suppress any actions if `--json` flag is present.
13+
*/
14+
export class MultiStageOutput<T extends Record<string, unknown>> extends OclifMultiStageOutput<T> {
15+
public constructor(opts: MultiStageOutputOptions<T> & { outputEnabled: boolean }) {
16+
if (opts.outputEnabled) super(opts);
17+
}
18+
}

src/ux/ux.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import ansis from 'ansis';
9-
import { ux } from '@oclif/core';
9+
import { ux } from '@oclif/core/ux';
1010
import { AnyJson } from '@salesforce/ts-types';
1111
import terminalLink from 'terminal-link';
1212
import { UxBase } from './base.js';

0 commit comments

Comments
 (0)