Skip to content
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

[v2] allow showMsgWhenDeprecated to accept an empty string as a parameter … #2226

Merged
merged 18 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
5 changes: 5 additions & 0 deletions packages/imperative/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to the Imperative package will be documented in this file.


## Recent Changes

- BugFix: Modified showMsgWhenDeprecated() function to allow an empty string as a parameter when no replacement is availible for the deprecated command. When no replacement is availible an alternative message will be printed. [#2041](https://github.com/zowe/zowe-cli/issues/2041)
jace-roell marked this conversation as resolved.
Show resolved Hide resolved

## `5.26.3`

- BugFix: Fixed issue in local web help with highlighted sidebar item getting out of sync. [#2215](https://github.com/zowe/zowe-cli/pull/2215)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,22 @@ describe("CliUtils", () => {
CliUtils.showMsgWhenDeprecated(handlerParms);
expect(responseErrText).toEqual("Recommended replacement: " +
handlerParms.definition.deprecatedReplacement);
expect(responseErrText).not.toContain("Obsolete component. No replacement exists");
});

it("should not produce a deprecated message when not deprecated", () => {
responseErrText = notSetYet;
delete handlerParms.definition.deprecatedReplacement;
CliUtils.showMsgWhenDeprecated(handlerParms);
expect(responseErrText).toEqual(notSetYet);
expect(responseErrText).not.toContain("Obsolete component. No replacement exists");
});

it("should produce alternative text when deprecatedReplacement is an empty string", () => {
jace-roell marked this conversation as resolved.
Show resolved Hide resolved
responseErrText = notSetYet;
handlerParms.definition.deprecatedReplacement = "";
CliUtils.showMsgWhenDeprecated(handlerParms);
expect(responseErrText).toContain("Obsolete component. No replacement exists");
});
});

Expand Down
28 changes: 17 additions & 11 deletions packages/imperative/src/utilities/src/CliUtils.ts
jace-roell marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,26 @@ export class CliUtils {
* @memberof CliUtils
*/
public static showMsgWhenDeprecated(handlerParms: IHandlerParameters) {
if (handlerParms.definition.deprecatedReplacement) {
jace-roell marked this conversation as resolved.
Show resolved Hide resolved
let oldCmd: string | number;
jace-roell marked this conversation as resolved.
Show resolved Hide resolved
if (handlerParms.definition.deprecatedReplacement || handlerParms.definition.deprecatedReplacement === "") {
// form the command that is deprecated
let oldCmd: string;
if (handlerParms.positionals.length >= 1) {
oldCmd = handlerParms.positionals[0];
if(handlerParms.definition.deprecatedReplacement === "")
{
handlerParms.response.console.error("\nObsolete component. No replacement exists");
jace-roell marked this conversation as resolved.
Show resolved Hide resolved
}
if (handlerParms.positionals.length >= 2) {
oldCmd = oldCmd + " " + handlerParms.positionals[1];
}

// display the message
handlerParms.response.console.error("\nWarning: The command '" + oldCmd + "' is deprecated.");
handlerParms.response.console.error("Recommended replacement: " +
else
{
if (handlerParms.positionals.length >= 1) {
oldCmd = handlerParms.positionals[0];
}
if (handlerParms.positionals.length >= 2) {
oldCmd = oldCmd + " " + handlerParms.positionals[1];
}
// display the message
handlerParms.response.console.error("\nWarning: The command '" + oldCmd + "' is deprecated.");
handlerParms.response.console.error("Recommended replacement: " +
handlerParms.definition.deprecatedReplacement);
}
}
}

Expand Down