Skip to content

Commit 23bf99a

Browse files
committed
less scrollbar with --verbose
1 parent 50e3b0c commit 23bf99a

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

src/api/BundlePush/BundlePusher.ts

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ export class BundlePusher {
7070
// Create an SSH session
7171
const sshSession = await this.createSshSession();
7272

73-
// Start a progress bar
73+
// Start a progress bar (but only in non-verbose mode)
7474
this.progressBar = { percentComplete: 0,
7575
statusMessage: "Starting Push operation",
7676
stageName: TaskStage.IN_PROGRESS };
77-
this.params.response.progress.startBar({task: this.progressBar});
77+
this.startProgressBar();
7878

7979
// Attempt to make the target bundledir
8080
await this.makeBundleDir(zosMFSession);
@@ -103,7 +103,7 @@ export class BundlePusher {
103103
// Run DFHDPLOY to install the bundle
104104
await this.deployBundle(zosMFSession, bd);
105105

106-
this.params.response.progress.endBar();
106+
this.endProgressBar();
107107
return "PUSH operation completed.";
108108
}
109109

@@ -223,37 +223,36 @@ export class BundlePusher {
223223
private async undeployExistingBundle(zosMFSession: AbstractSession, bd: BundleDeployer) {
224224
// End the current progress bar so that UNDEPLOY can create its own
225225
this.updateStatus("Undeploying any existing bundle from CICS");
226-
this.params.response.progress.endBar();
226+
this.endProgressBar();
227+
227228

228229
const targetstateLocal = this.params.arguments.targetstate;
229230
this.params.arguments.targetstate = "DISCARDED";
230231
await bd.undeployBundle(zosMFSession);
231232
this.params.arguments.targetstate = targetstateLocal;
232233

233234
// Resume the current progress bar
234-
this.params.response.progress.endBar();
235+
this.endProgressBar();
235236
this.updateStatus("Undeployed existing bundle from CICS");
236-
this.params.response.progress.startBar({task: this.progressBar});
237+
this.startProgressBar();
237238
}
238239

239240
private async deployBundle(zosMFSession: AbstractSession, bd: BundleDeployer) {
240241
// End the current progress bar so that DEPLOY can create its own
241242
this.updateStatus("Deploying the bundle to CICS");
242-
this.params.response.progress.endBar();
243+
this.endProgressBar();
243244

244245
await bd.deployBundle(zosMFSession);
245246
// Resume the current progress bar
246-
this.params.response.progress.endBar();
247+
this.endProgressBar();
247248
this.updateStatus("Deployed existing bundle to CICS");
248-
this.params.response.progress.startBar({task: this.progressBar});
249+
this.startProgressBar();
249250
}
250251

251252
private sshOutput(data: string) {
252253
// If verbose output is requested then log SSH output directly to the console
253254
if (this.params.arguments.verbose) {
254-
this.params.response.progress.endBar();
255255
this.params.response.console.log(Buffer.from(data));
256-
this.params.response.progress.startBar({task: this.progressBar});
257256
}
258257
this.sshOutputText += data;
259258
}
@@ -342,7 +341,7 @@ export class BundlePusher {
342341
// if we've not already logged the output, log it now
343342
if (this.params.arguments.verbose !== true)
344343
{
345-
this.params.response.console.log(this.sshOutputText);
344+
this.params.response.console.log(Buffer.from(this.sshOutputText));
346345
}
347346
throw new Error("The output from the remote command implied that an error occurred.");
348347
}
@@ -383,13 +382,13 @@ export class BundlePusher {
383382

384383
// A project specific .zosattributes has not been found, so use a default
385384
const warningMsg = "WARNING: No .zosAttributes file found in the bundle directory, default values will be applied.";
386-
this.params.response.progress.endBar();
387-
this.params.response.console.log(warningMsg);
385+
this.endProgressBar();
386+
this.params.response.console.log(Buffer.from(warningMsg));
388387
if (this.params.arguments.silent === undefined) {
389388
const logger = Logger.getAppLogger();
390389
logger.warn(warningMsg);
391390
}
392-
this.params.response.progress.startBar({task: this.progressBar});
391+
this.startProgressBar();
393392
return new ZosFilesAttributes(Bundle.getTemplateZosAttributesFile());
394393
}
395394

@@ -399,12 +398,24 @@ export class BundlePusher {
399398
this.progressBar.statusMessage = status;
400399

401400
if (this.params.arguments.verbose) {
402-
this.params.response.console.log(status + "\n");
401+
this.params.response.console.log(Buffer.from(status + "\n"));
403402
}
404403

405404
if (this.params.arguments.silent === undefined) {
406405
const logger = Logger.getAppLogger();
407406
logger.debug(status);
408407
}
409408
}
409+
410+
private startProgressBar() {
411+
if (this.params.arguments.verbose !== true) {
412+
this.params.response.progress.startBar({task: this.progressBar});
413+
}
414+
}
415+
416+
private endProgressBar() {
417+
if (this.params.arguments.verbose !== true) {
418+
this.params.response.progress.endBar();
419+
}
420+
}
410421
}

src/cli/shared/BundleParent.handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export abstract class BundleParentHandler implements ICommandHandler {
5555
msg = await this.performAction(params);
5656

5757
// Issue the success message
58-
params.response.console.log(msg);
58+
params.response.console.log(Buffer.from(msg));
5959
if (params.arguments.silent === undefined) {
6060
logger.debug(msg);
6161
}

0 commit comments

Comments
 (0)