diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 2a7c9fc4a8..600caf7f87 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,6 +1,10 @@ # Change Log All notable changes to the Zowe CLI package will be documented in this file. +## Recent Changes + +- BugFix: Fixed an issue where the `zowe files upload dir-to-uss` command was missing progress bar to track progress of file uploads. [#2344](https://github.com/zowe/zowe-cli/issues/2344) + ## `8.10.3` - BugFix: The `zowe files copy data-set` command no longer copies all partitioned data set members if a member is specified. [#2402](https://github.com/zowe/zowe-cli/pull/2402) diff --git a/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts b/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts index f5c406ac37..44bf308634 100644 --- a/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts +++ b/packages/cli/src/zosfiles/upload/dtu/DirToUSSDir.handler.ts @@ -54,12 +54,19 @@ export default class DirToUSSDirHandler extends ZosFilesBaseHandler { uploadOptions.filesMap = this.buildFilesMap(commandParameters); } - const uploadApi = commandParameters.arguments.recursive ? Upload.dirToUSSDirRecursive : Upload.dirToUSSDir; - const response = await uploadApi.bind(Upload)(session, inputDir, commandParameters.arguments.USSDir, uploadOptions); + commandParameters.response.progress.startBar({ task: status }); - const formatMessage = TextUtils.prettyJson(response.apiResponse); - commandParameters.response.console.log(formatMessage); - return response; + try { + const uploadApi = commandParameters.arguments.recursive ? Upload.dirToUSSDirRecursive : Upload.dirToUSSDir; + const response = await uploadApi.bind(Upload)(session, inputDir, commandParameters.arguments.USSDir, uploadOptions); + + const formatMessage = TextUtils.prettyJson(response.apiResponse); + commandParameters.response.console.log(formatMessage); + + return response; + } finally { + commandParameters.response.progress.endBar(); + } } private buildFilesMap(commandParameters: IHandlerParameters) { diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 6434c10063..375e966ec4 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to the Imperative package will be documented in this file. ## Recent Changes - Enhancement: Added `DeferredPromise` class to Imperative to provide utilities for data synchronization. [#2405](https://github.com/zowe/zowe-cli/pull/2405) +- BugFix: Fixed a typo in the syntax validation code for positional arguments which caused the validation to never fail. [#2375](https://github.com/zowe/zowe-cli/issues/2375) ## `8.10.3` diff --git a/packages/imperative/src/cmd/src/syntax/SyntaxValidator.ts b/packages/imperative/src/cmd/src/syntax/SyntaxValidator.ts index ea0b0be56b..b95dad3974 100644 --- a/packages/imperative/src/cmd/src/syntax/SyntaxValidator.ts +++ b/packages/imperative/src/cmd/src/syntax/SyntaxValidator.ts @@ -226,7 +226,7 @@ export class SyntaxValidator { if (!(commandArguments[positional.name] == null)) { if (positional.regex) { if (commandArguments[positional.name] - .toString().match(new RegExp(positional.regex) == null)) { + .toString().match(new RegExp(positional.regex)) == null) { valid = false; this.positionalParameterInvalid(positional, commandArguments[positional.name], responseObject); diff --git a/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts b/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts index 58bf12a29c..db03e257c3 100644 --- a/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts +++ b/packages/imperative/src/cmd/src/syntax/__tests__/SyntaxValidator.unit.test.ts @@ -46,6 +46,9 @@ describe("Imperative should provide advanced syntax validation rules", () => { function tryOptions(optionString: string, shouldSucceed: boolean, expectedText?: string[]) { const options = yargsParser.detailed(optionString, configuration).argv; + ValidationTestCommand.positionals?.forEach((p) => { + options[p.name] = options._.shift(); // fake out named positionals + }); options._ = ["test", "validation-test"].concat(options._ || []); // fake out command structure options[Constants.JSON_OPTION] = true; delete options["--"]; // delete extra yargs parse field @@ -525,6 +528,28 @@ describe("Imperative should provide advanced syntax validation rules", () => { expect(svResponse.valid).toEqual(true); }); + it("should fail if a positional argument does not match the defined regex", async () => { + const invalidPositional = "invalid_value"; + const regexForPositional = "^\\w+$"; + ValidationTestCommand.positionals = [{ + name: invalidPositional, + type: "string", + description: "Invalid positional", + regex: regexForPositional, + }]; + + return tryOptions.bind(this)( + minValidOptions + "inv@lid", + false, + [ + "Invalid format specified for positional option:", + invalidPositional, + "Option must match the following regular expression:", + regexForPositional + ] + ); + }); + describe("We should be able to validate positional arguments of type 'number'", () => { const numberCommand: ICommandDefinition = { name: "gimme-number", aliases: [],