Skip to content

feat: add MultiStageOutput #615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@salesforce/sf-plugins-core",
"version": "11.3.2",
"version": "11.3.3-dev.3",
"description": "Utils for writing Salesforce CLI plugins",
"main": "lib/exported",
"types": "lib/exported.d.ts",
Expand Down Expand Up @@ -47,6 +47,7 @@
"@inquirer/confirm": "^3.1.22",
"@inquirer/password": "^2.1.22",
"@oclif/core": "^4.0.15",
"@oclif/multi-stage-output": "^0.2.2",
"@salesforce/core": "^8.2.7",
"@salesforce/kit": "^3.2.1",
"@salesforce/ts-types": "^2.0.12",
Expand Down
10 changes: 10 additions & 0 deletions src/sfCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -314,6 +315,15 @@ export abstract class SfCommand<T> extends Command {
return confirm({ message, ms, defaultAnswer });
}

public initStager<O extends Record<string, unknown>>(options: MultiStageOutputOptions<O>): MultiStageOutput<O> {
const ms = new MultiStageOutput<O>(options);
if (this.jsonEnabled()) {
ms.stop();
}

return ms;
}

public async _run<R>(): Promise<R> {
['SIGINT', 'SIGTERM', 'SIGBREAK', 'SIGHUP'].map((listener) => {
process.on(listener, () => {
Expand Down
2 changes: 1 addition & 1 deletion src/ux/ux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import ansis from 'ansis';
import { ux } from '@oclif/core';
import { ux } from '@oclif/core/ux';
import { AnyJson } from '@salesforce/ts-types';
import terminalLink from 'terminal-link';
import { UxBase } from './base.js';
Expand Down
Loading