Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #42 from zowe/fix-daemon-mode
Browse files Browse the repository at this point in the history
Fix daemon mode prompting, remove API call causing error
  • Loading branch information
zFernand0 authored Apr 8, 2022
2 parents 0fbfe6f + c00069b commit fcdc01e
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 42 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to the IBM® IMS™ Plug-in for Zowe CLI will be documented in this file.

## Recent Changes

- BugFix: Removed deprecated profiles API calls
- BugFix: Fixed prompting in daemon mode

## `3.0.0-next.202202071747`

- BugFix: Pruned dev dependencies from npm-shrinkwrap file.
Expand Down
13 changes: 6 additions & 7 deletions src/cli/ImsBaseHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* *
*/

import { ICommandHandler, IHandlerParameters, ImperativeError, IProfile, TextUtils } from "@zowe/imperative";
import { ICommandHandler, IHandlerParameters, ImperativeError, TextUtils } from "@zowe/imperative";
import { IIMSApiResponse } from "../api/doc/IIMSApiResponse";
import { ImsSessionUtils } from "./ImsSessionUtils";
import { ImsSession } from "../api/rest";
Expand All @@ -35,13 +35,14 @@ export abstract class ImsBaseHandler implements ICommandHandler {
*/
public async process(commandParameters: IHandlerParameters) {
this.params = commandParameters;
const profile = commandParameters.profiles.get("ims", false) || {};

const session: ImsSession = await ImsSessionUtils.createSessCfgFromArgs(
commandParameters.arguments
commandParameters.arguments,
true,
commandParameters
);

const response = await this.processWithSession(commandParameters, session, profile);
const response = await this.processWithSession(commandParameters, session);

commandParameters.response.progress.endBar(); // end any progress bars

Expand All @@ -55,14 +56,12 @@ export abstract class ImsBaseHandler implements ICommandHandler {
*
* @param {IHandlerParameters} commandParameters Command parameters sent to the handler.
* @param {ImsSession} session The session object generated from the ims profile.
* @param {IProfile} imsProfile The ims profile that was loaded for the command.
*
* @returns {Promise<IIMSApiResponse>} The response from the underlying ims api call.
*/
public abstract async processWithSession(
commandParameters: IHandlerParameters,
session: ImsSession,
imsProfile: IProfile
session: ImsSession
): Promise<IIMSApiResponse>;

/**
Expand Down
7 changes: 4 additions & 3 deletions src/cli/ImsSessionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* *
*/

import { ConnectionPropsForSessCfg, ICommandArguments, ICommandOptionDefinition, ISession, Logger, SessConstants } from "@zowe/imperative";
import { ConnectionPropsForSessCfg, ICommandArguments, ICommandOptionDefinition,
IHandlerParameters, ISession, Logger, SessConstants } from "@zowe/imperative";
import { ImsConstants } from "../api/constants/Ims.constants";
import { ImsSession } from "../api/rest/ImsSession";

Expand Down Expand Up @@ -139,7 +140,7 @@ export class ImsSessionUtils {
ImsSessionUtils.IMS_OPTION_PROTOCOL,
];

public static async createSessCfgFromArgs(args: ICommandArguments, doPrompting = true): Promise<ImsSession> {
public static async createSessCfgFromArgs(args: ICommandArguments, doPrompting = true, handlerParams?: IHandlerParameters): Promise<ImsSession> {
this.log.debug("Creating a IMS session from arguments");
const basePath = args.basePath;// ?? ImsConstants.BASE_PATH;

Expand Down Expand Up @@ -169,7 +170,7 @@ export class ImsSessionUtils {
sessCfg.type = SessConstants.AUTH_TYPE_BASIC;
}

const sessCfgWithCreds = await ConnectionPropsForSessCfg.addPropsOrPrompt<ISession>(sessCfg, args, {doPrompting});
const sessCfgWithCreds = await ConnectionPropsForSessCfg.addPropsOrPrompt<ISession>(sessCfg, args, {doPrompting, parms: handlerParams});

return new ImsSession({
...sessCfgWithCreds,
Expand Down
5 changes: 2 additions & 3 deletions src/cli/query/program/Program.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* *
*/

import { IHandlerParameters, IProfile, ITaskWithStatus, TaskStage } from "@zowe/imperative";
import { IHandlerParameters, ITaskWithStatus, TaskStage } from "@zowe/imperative";
import { IIMSApiResponse, ImsSession, queryProgram } from "../../../api";
import { ImsBaseHandler } from "../../ImsBaseHandler";

Expand All @@ -21,8 +21,7 @@ import { ImsBaseHandler } from "../../ImsBaseHandler";
*/
export default class ProgramHandler extends ImsBaseHandler {
public async processWithSession(params: IHandlerParameters,
session: ImsSession,
profile: IProfile): Promise<IIMSApiResponse> {
session: ImsSession): Promise<IIMSApiResponse> {

const status: ITaskWithStatus = {
statusMessage: "Querying program defined to IMS",
Expand Down
5 changes: 2 additions & 3 deletions src/cli/query/region/Region.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* *
*/

import { IHandlerParameters, IProfile, ITaskWithStatus, TaskStage } from "@zowe/imperative";
import { IHandlerParameters, ITaskWithStatus, TaskStage } from "@zowe/imperative";
import { IIMSApiResponse, ImsSession, queryRegion } from "../../../api";
import { ImsBaseHandler } from "../../ImsBaseHandler";

Expand All @@ -21,8 +21,7 @@ import { ImsBaseHandler } from "../../ImsBaseHandler";
*/
export default class RegionHandler extends ImsBaseHandler {
public async processWithSession(params: IHandlerParameters,
session: ImsSession,
profile: IProfile): Promise<IIMSApiResponse> {
session: ImsSession): Promise<IIMSApiResponse> {

const status: ITaskWithStatus = {
statusMessage: "Querying region defined to IMS",
Expand Down
4 changes: 2 additions & 2 deletions src/cli/query/transaction/Transaction.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* *
*/

import { IHandlerParameters, IProfile, ITaskWithStatus, Logger, TaskStage } from "@zowe/imperative";
import { IHandlerParameters, ITaskWithStatus, Logger, TaskStage } from "@zowe/imperative";
import { IIMSApiResponse, ImsSession, queryTransaction } from "../../../api";
import { ImsBaseHandler } from "../../ImsBaseHandler";

Expand All @@ -20,7 +20,7 @@ import { ImsBaseHandler } from "../../ImsBaseHandler";
* @implements {ICommandHandler}
*/
export default class TransactionHandler extends ImsBaseHandler {
public async processWithSession(params: IHandlerParameters, session: ImsSession, profile: IProfile): Promise<IIMSApiResponse> {
public async processWithSession(params: IHandlerParameters, session: ImsSession): Promise<IIMSApiResponse> {

const status: ITaskWithStatus = {
statusMessage: "Querying resources from IMS",
Expand Down
5 changes: 2 additions & 3 deletions src/cli/start/program/Program.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* *
*/

import { IHandlerParameters, IProfile, ITaskWithStatus, Logger, TaskStage, TextUtils } from "@zowe/imperative";
import { IHandlerParameters, ITaskWithStatus, Logger, TaskStage, TextUtils } from "@zowe/imperative";
import { IIMSApiResponse, ImsSession, startProgram } from "../../../api";
import { ImsBaseHandler } from "../../ImsBaseHandler";

Expand All @@ -21,8 +21,7 @@ import { ImsBaseHandler } from "../../ImsBaseHandler";
*/
export default class ProgramHandler extends ImsBaseHandler {
public async processWithSession(params: IHandlerParameters,
session: ImsSession,
profile: IProfile): Promise<IIMSApiResponse> {
session: ImsSession): Promise<IIMSApiResponse> {

const status: ITaskWithStatus = {
statusMessage: "Start program defined to IMS",
Expand Down
5 changes: 2 additions & 3 deletions src/cli/start/region/Region.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* *
*/

import { IHandlerParameters, IProfile, ITaskWithStatus, Logger, TaskStage, TextUtils } from "@zowe/imperative";
import { IHandlerParameters, ITaskWithStatus, Logger, TaskStage, TextUtils } from "@zowe/imperative";
import { IIMSApiResponse, ImsSession, startRegion } from "../../../api";
import { ImsBaseHandler } from "../../ImsBaseHandler";

Expand All @@ -21,8 +21,7 @@ import { ImsBaseHandler } from "../../ImsBaseHandler";
*/
export default class RegionHandler extends ImsBaseHandler {
public async processWithSession(params: IHandlerParameters,
session: ImsSession,
profile: IProfile): Promise<IIMSApiResponse> {
session: ImsSession): Promise<IIMSApiResponse> {

const status: ITaskWithStatus = {
statusMessage: "Starting region defined to IMS",
Expand Down
4 changes: 1 addition & 3 deletions src/cli/start/transaction/Transaction.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import {
IHandlerParameters,
IProfile,
ITaskWithStatus, Logger,
TaskStage,
TextUtils
Expand All @@ -27,8 +26,7 @@ import { ImsBaseHandler } from "../../ImsBaseHandler";
*/
export default class TransactionHandler extends ImsBaseHandler {
public async processWithSession(params: IHandlerParameters,
session: ImsSession,
profile: IProfile): Promise<IIMSApiResponse> {
session: ImsSession): Promise<IIMSApiResponse> {

const status: ITaskWithStatus = {
statusMessage: "Start transaction defined to IMS",
Expand Down
4 changes: 1 addition & 3 deletions src/cli/stop/program/Program.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import {
IHandlerParameters,
IProfile,
ITaskWithStatus, Logger,
TaskStage,
TextUtils
Expand All @@ -27,8 +26,7 @@ import { ImsBaseHandler } from "../../ImsBaseHandler";
*/
export default class ProgramHandler extends ImsBaseHandler {
public async processWithSession(params: IHandlerParameters,
session: ImsSession,
profile: IProfile): Promise<IIMSApiResponse> {
session: ImsSession): Promise<IIMSApiResponse> {

const status: ITaskWithStatus = {
statusMessage: "Stop program defined to IMS",
Expand Down
5 changes: 2 additions & 3 deletions src/cli/stop/region/Region.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* *
*/

import { IHandlerParameters, IProfile, ITaskWithStatus, Logger, TaskStage, TextUtils } from "@zowe/imperative";
import { IHandlerParameters, ITaskWithStatus, Logger, TaskStage, TextUtils } from "@zowe/imperative";
import { IIMSApiResponse, ImsSession, stopRegion } from "../../../api";
import { ImsBaseHandler } from "../../ImsBaseHandler";

Expand All @@ -21,8 +21,7 @@ import { ImsBaseHandler } from "../../ImsBaseHandler";
*/
export default class RegionHandler extends ImsBaseHandler {
public async processWithSession(params: IHandlerParameters,
session: ImsSession,
profile: IProfile): Promise<IIMSApiResponse> {
session: ImsSession): Promise<IIMSApiResponse> {

const status: ITaskWithStatus = {
statusMessage: "Stop region defined to IMS",
Expand Down
4 changes: 1 addition & 3 deletions src/cli/stop/transaction/Transaction.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import {
IHandlerParameters,
IProfile,
ITaskWithStatus, Logger,
TaskStage,
TextUtils
Expand All @@ -27,8 +26,7 @@ import { ImsBaseHandler } from "../../ImsBaseHandler";
*/
export default class TransactionHandler extends ImsBaseHandler {
public async processWithSession(params: IHandlerParameters,
session: ImsSession,
profile: IProfile): Promise<IIMSApiResponse> {
session: ImsSession): Promise<IIMSApiResponse> {

const status: ITaskWithStatus = {
statusMessage: "Stop transaction defined to IMS",
Expand Down
5 changes: 2 additions & 3 deletions src/cli/update/program/Program.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* *
*/

import { IHandlerParameters, IProfile, ITaskWithStatus, Logger, TaskStage, TextUtils } from "@zowe/imperative";
import { IHandlerParameters, ITaskWithStatus, Logger, TaskStage, TextUtils } from "@zowe/imperative";
import { IIMSApiResponse, ImsSession, updateProgram } from "../../../api";
import { ImsBaseHandler } from "../../ImsBaseHandler";

Expand All @@ -21,8 +21,7 @@ import { ImsBaseHandler } from "../../ImsBaseHandler";
*/
export default class ProgramHandler extends ImsBaseHandler {
public async processWithSession(params: IHandlerParameters,
session: ImsSession,
profile: IProfile): Promise<IIMSApiResponse> {
session: ImsSession): Promise<IIMSApiResponse> {

const status: ITaskWithStatus = {
statusMessage: "Update program defined to IMS",
Expand Down
4 changes: 1 addition & 3 deletions src/cli/update/transaction/Transaction.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import {
IHandlerParameters,
IProfile,
ITaskWithStatus, Logger,
TaskStage,
TextUtils
Expand All @@ -27,8 +26,7 @@ import { ImsBaseHandler } from "../../ImsBaseHandler";
*/
export default class TransactionHandler extends ImsBaseHandler {
public async processWithSession(params: IHandlerParameters,
session: ImsSession,
profile: IProfile): Promise<IIMSApiResponse> {
session: ImsSession): Promise<IIMSApiResponse> {

const status: ITaskWithStatus = {
statusMessage: "update transaction defined to IMS",
Expand Down

0 comments on commit fcdc01e

Please sign in to comment.