diff --git a/.gitignore b/.gitignore index 21500acf9a..40c8b7d7ea 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ CCS141/ src/brightside.iml package-lock.json /packages/cli/npm-shrinkwrap.json +/zowe-cli /dist/ # Sonar Files .sonar_lock diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 745d689594..0d0b643a64 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,10 +1,10 @@ # Change Log - All notable changes to the Zowe CLI package will be documented in this file. ## Recent Changes - BugFix: Added support for the `--encoding` flag to the `zowe upload dir-to-uss` to allow for encoding uploaded directories for command group consistency. [#2337](https://github.com/zowe/zowe-cli/issues/2337) +- Enhancement: Add the --ignore-not-found flag to avoid file-not-found error messages when deleting files so scripts are not interupted during automated batch processing. The flag bypasses warning prompts to confirm delete actions. [#2254](https://github.com/zowe/zowe-cli/pull/2254) ## `8.7.0` @@ -26,6 +26,7 @@ All notable changes to the Zowe CLI package will be documented in this file. - Enhancement: Added optional `--attributes` flag to `zowe zos-files upload file-to-uss` to allow passing a .zosattributes file path for upload encoding format. [#2319](https://github.com/zowe/zowe-cli/pull/2319) + ## `8.3.0` - Enhancement: Issue the `zowe files search data-sets` command with the new `encoding` option to use a different code page when searching data set contents. [#2161](https://github.com/zowe/zowe-cli/issues/2161) diff --git a/packages/cli/__tests__/zosfiles/__integration__/delete/ds/__snapshots__/cli.files.delete.ds.integration.test.ts.snap b/packages/cli/__tests__/zosfiles/__integration__/delete/ds/__snapshots__/cli.files.delete.ds.integration.test.ts.snap index 52ad2259ab..15ec733ef1 100644 --- a/packages/cli/__tests__/zosfiles/__integration__/delete/ds/__snapshots__/cli.files.delete.ds.integration.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__integration__/delete/ds/__snapshots__/cli.files.delete.ds.integration.test.ts.snap @@ -35,6 +35,10 @@ exports[`Delete Data Set should display the help 1`] = ` OPTIONS ------- + --ignore-not-found | -i | --inf (boolean) + + Suppress errors if the data set does not exist. + --volume | --vol (string) The volume serial (VOLSER) where the data set resides. The option is required @@ -147,13 +151,18 @@ exports[`Delete Data Set should display the help 1`] = ` $ zowe zos-files delete data-set \\"ibmuser.cntl(mem)\\" -f + - Quietly delete a data set, suppressing errors if it doesn't + exist: + + $ zowe zos-files delete data-set \\"ibmuser.cntl(mem)\\" -fi + ================Z/OS CFILES CREATE HELP WITH RFJ=========== { \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: data-set.\\", - \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n data-set | ds\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a data set or data set member permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete data-set [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n dataSetName\\\\t\\\\t (string)\\\\n\\\\n The name of the data set that you want to delete\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the data set permanently.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --volume | --vol (string)\\\\n\\\\n The volume serial (VOLSER) where the data set resides. The option is required\\\\n only when the data set is not catalogued on the system.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the data set named 'ibmuser.cntl':\\\\n\\\\n $ zowe zos-files delete data-set \\\\\\"ibmuser.cntl\\\\\\" -f\\\\n\\\\n - Delete the data set member named 'ibmuser.cntl(mem)':\\\\n\\\\n $ zowe zos-files delete data-set \\\\\\"ibmuser.cntl(mem)\\\\\\" -f\\\\n\\\\n\\", + \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n data-set | ds\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a data set or data set member permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete data-set [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n dataSetName\\\\t\\\\t (string)\\\\n\\\\n The name of the data set that you want to delete\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the data set permanently.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --ignore-not-found | -i | --inf (boolean)\\\\n\\\\n Suppress errors if the data set does not exist.\\\\n\\\\n --volume | --vol (string)\\\\n\\\\n The volume serial (VOLSER) where the data set resides. The option is required\\\\n only when the data set is not catalogued on the system.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the data set named 'ibmuser.cntl':\\\\n\\\\n $ zowe zos-files delete data-set \\\\\\"ibmuser.cntl\\\\\\" -f\\\\n\\\\n - Delete the data set member named 'ibmuser.cntl(mem)':\\\\n\\\\n $ zowe zos-files delete data-set \\\\\\"ibmuser.cntl(mem)\\\\\\" -f\\\\n\\\\n - Quietly delete a data set, suppressing errors if it doesn't\\\\n exist:\\\\n\\\\n $ zowe zos-files delete data-set \\\\\\"ibmuser.cntl(mem)\\\\\\" -fi\\\\n\\\\n\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n data-set | ds\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a data set or data set member permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete data-set [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n dataSetName\\\\t\\\\t (string)\\\\n\\\\n The name of the data set that you want to delete\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the data set permanently.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --volume | --vol (string)\\\\n\\\\n The volume serial (VOLSER) where the data set resides. The option is required\\\\n only when the data set is not catalogued on the system.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the data set named 'ibmuser.cntl':\\\\n\\\\n $ zowe zos-files delete data-set \\\\\\"ibmuser.cntl\\\\\\" -f\\\\n\\\\n - Delete the data set member named 'ibmuser.cntl(mem)':\\\\n\\\\n $ zowe zos-files delete data-set \\\\\\"ibmuser.cntl(mem)\\\\\\" -f\\\\n\\\\n\\" + \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n data-set | ds\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a data set or data set member permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete data-set [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n dataSetName\\\\t\\\\t (string)\\\\n\\\\n The name of the data set that you want to delete\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the data set permanently.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --ignore-not-found | -i | --inf (boolean)\\\\n\\\\n Suppress errors if the data set does not exist.\\\\n\\\\n --volume | --vol (string)\\\\n\\\\n The volume serial (VOLSER) where the data set resides. The option is required\\\\n only when the data set is not catalogued on the system.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the data set named 'ibmuser.cntl':\\\\n\\\\n $ zowe zos-files delete data-set \\\\\\"ibmuser.cntl\\\\\\" -f\\\\n\\\\n - Delete the data set member named 'ibmuser.cntl(mem)':\\\\n\\\\n $ zowe zos-files delete data-set \\\\\\"ibmuser.cntl(mem)\\\\\\" -f\\\\n\\\\n - Quietly delete a data set, suppressing errors if it doesn't\\\\n exist:\\\\n\\\\n $ zowe zos-files delete data-set \\\\\\"ibmuser.cntl(mem)\\\\\\" -fi\\\\n\\\\n\\" }" `; diff --git a/packages/cli/__tests__/zosfiles/__integration__/delete/uss/__snapshots__/cli.files.delete.uss.integration.test.ts.snap b/packages/cli/__tests__/zosfiles/__integration__/delete/uss/__snapshots__/cli.files.delete.uss.integration.test.ts.snap index 562158c9b3..3d08ac2612 100644 --- a/packages/cli/__tests__/zosfiles/__integration__/delete/uss/__snapshots__/cli.files.delete.uss.integration.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__integration__/delete/uss/__snapshots__/cli.files.delete.uss.integration.test.ts.snap @@ -40,6 +40,10 @@ exports[`Delete USS File should display the help 1`] = ` Delete directories recursively. + --ignore-not-found | -i | --inf (boolean) + + Suppress errors if the file does not exist. + --response-timeout | --rto (number) The maximum amount of time in seconds the z/OSMF Files TSO servlet should run @@ -152,13 +156,18 @@ exports[`Delete USS File should display the help 1`] = ` $ zowe zos-files delete uss-file \\"/a/ibmuser/testcases\\" -rf + - Quietly delete a file, suppressing errors if the file + doesn't exist: + + $ zowe zos-files delete uss-file \\"/a/ibmuser/testcases\\" -fi + ================Z/OS CFILES CREATE HELP WITH RFJ=========== { \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: uss-file.\\", - \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n uss-file | uf | uss\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a Unix Systems Services (USS) file or directory permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete uss-file [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n fileName\\\\t\\\\t (string)\\\\n\\\\n The name of the file or directory that you want to delete\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the file or directory\\\\n permanently.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --recursive | -r (boolean)\\\\n\\\\n Delete directories recursively.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the empty directory '/u/ibmuser/testcases':\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases\\\\\\" -f\\\\n\\\\n - Delete the file named '/a/ibmuser/my_text.txt':\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases/my_text.txt\\\\\\" -f\\\\n\\\\n - Recursively delete the directory named\\\\n '/u/ibmuser/testcases':\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases\\\\\\" -rf\\\\n\\\\n\\", + \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n uss-file | uf | uss\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a Unix Systems Services (USS) file or directory permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete uss-file [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n fileName\\\\t\\\\t (string)\\\\n\\\\n The name of the file or directory that you want to delete\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the file or directory\\\\n permanently.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --recursive | -r (boolean)\\\\n\\\\n Delete directories recursively.\\\\n\\\\n --ignore-not-found | -i | --inf (boolean)\\\\n\\\\n Suppress errors if the file does not exist.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the empty directory '/u/ibmuser/testcases':\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases\\\\\\" -f\\\\n\\\\n - Delete the file named '/a/ibmuser/my_text.txt':\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases/my_text.txt\\\\\\" -f\\\\n\\\\n - Recursively delete the directory named\\\\n '/u/ibmuser/testcases':\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases\\\\\\" -rf\\\\n\\\\n - Quietly delete a file, suppressing errors if the file\\\\n doesn't exist:\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases\\\\\\" -fi\\\\n\\\\n\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n uss-file | uf | uss\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a Unix Systems Services (USS) file or directory permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete uss-file [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n fileName\\\\t\\\\t (string)\\\\n\\\\n The name of the file or directory that you want to delete\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the file or directory\\\\n permanently.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --recursive | -r (boolean)\\\\n\\\\n Delete directories recursively.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the empty directory '/u/ibmuser/testcases':\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases\\\\\\" -f\\\\n\\\\n - Delete the file named '/a/ibmuser/my_text.txt':\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases/my_text.txt\\\\\\" -f\\\\n\\\\n - Recursively delete the directory named\\\\n '/u/ibmuser/testcases':\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases\\\\\\" -rf\\\\n\\\\n\\" + \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n uss-file | uf | uss\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a Unix Systems Services (USS) file or directory permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete uss-file [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n fileName\\\\t\\\\t (string)\\\\n\\\\n The name of the file or directory that you want to delete\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the file or directory\\\\n permanently.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --recursive | -r (boolean)\\\\n\\\\n Delete directories recursively.\\\\n\\\\n --ignore-not-found | -i | --inf (boolean)\\\\n\\\\n Suppress errors if the file does not exist.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the empty directory '/u/ibmuser/testcases':\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases\\\\\\" -f\\\\n\\\\n - Delete the file named '/a/ibmuser/my_text.txt':\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases/my_text.txt\\\\\\" -f\\\\n\\\\n - Recursively delete the directory named\\\\n '/u/ibmuser/testcases':\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases\\\\\\" -rf\\\\n\\\\n - Quietly delete a file, suppressing errors if the file\\\\n doesn't exist:\\\\n\\\\n $ zowe zos-files delete uss-file \\\\\\"/a/ibmuser/testcases\\\\\\" -fi\\\\n\\\\n\\" }" `; diff --git a/packages/cli/__tests__/zosfiles/__integration__/delete/vsam/__snapshots__/cli.files.delete.vsam.integration.test.ts.snap b/packages/cli/__tests__/zosfiles/__integration__/delete/vsam/__snapshots__/cli.files.delete.vsam.integration.test.ts.snap index 2d5e2e8ee0..487ea20c5b 100644 --- a/packages/cli/__tests__/zosfiles/__integration__/delete/vsam/__snapshots__/cli.files.delete.vsam.integration.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__integration__/delete/vsam/__snapshots__/cli.files.delete.vsam.integration.test.ts.snap @@ -36,6 +36,10 @@ exports[`Delete VSAM Data Set should display delete vsam help 1`] = ` Default value: false + --ignore-not-found | -i | --inf (boolean) + + Suppress errors if the VSAM data set does not exist. + --purge | -p (boolean) Specify this option to delete the VSAM cluster regardless of its retention @@ -154,8 +158,8 @@ exports[`Delete VSAM Data Set should display delete vsam help 1`] = ` $ zowe zos-files delete data-set-vsam \\"ibmuser.cntl.vsam\\" -f - - Delete all expired VSAM data sets that match - 'ibmuser.AAA.**.FFF': + - Quietly delete all VSAM data sets that match + 'ibmuser.AAA.**.FFF' ignoring not-found errors: $ zowe zos-files delete data-set-vsam \\"ibmuser.AAA.**.FFF\\" -f @@ -169,13 +173,18 @@ exports[`Delete VSAM Data Set should display delete vsam help 1`] = ` $ zowe zos-files delete data-set-vsam \\"ibmuser.cntl.vsam\\" -f --erase + - Quietly delete all VSAM data sets that match + 'ibmuser.AAA.**.FFF' ignoring not-found errors: + + $ zowe zos-files delete data-set-vsam \\"ibmuser.cntl.vsam\\" -fi + ================Z/OS FILES DELETE HELP WITH RFJ=========== { \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: data-set-vsam.\\", - \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n data-set-vsam | vsam\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a VSAM cluster permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete data-set-vsam [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n dataSetName\\\\t\\\\t (string)\\\\n\\\\n The name of the VSAM cluster that you want to delete\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --erase | -e (boolean)\\\\n\\\\n Specify this option to overwrite the data component for the cluster with binary\\\\n zeros. This option is ignored if the NOERASE attribute was specified when the\\\\n cluster was defined or altered.\\\\n\\\\n Default value: false\\\\n\\\\n --purge | -p (boolean)\\\\n\\\\n Specify this option to delete the VSAM cluster regardless of its retention\\\\n period or date.\\\\n\\\\n Default value: false\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the VSAM cluster\\\\n permanently.\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the VSAM data set named 'ibmuser.cntl.vsam':\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -f\\\\n\\\\n - Delete all expired VSAM data sets that match\\\\n 'ibmuser.AAA.**.FFF':\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.AAA.**.FFF\\\\\\" -f\\\\n\\\\n - Delete a non-expired VSAM data set named\\\\n 'ibmuser.cntl.vsam':\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -f --purge\\\\n\\\\n - Delete an expired VSAM data set named 'ibmuser.cntl.vsam'\\\\n by overwriting the components with zeros:\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -f --erase\\\\n\\\\n\\", + \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n data-set-vsam | vsam\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a VSAM cluster permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete data-set-vsam [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n dataSetName\\\\t\\\\t (string)\\\\n\\\\n The name of the VSAM cluster that you want to delete\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --erase | -e (boolean)\\\\n\\\\n Specify this option to overwrite the data component for the cluster with binary\\\\n zeros. This option is ignored if the NOERASE attribute was specified when the\\\\n cluster was defined or altered.\\\\n\\\\n Default value: false\\\\n\\\\n --ignore-not-found | -i | --inf (boolean)\\\\n\\\\n Suppress errors if the VSAM data set does not exist.\\\\n\\\\n --purge | -p (boolean)\\\\n\\\\n Specify this option to delete the VSAM cluster regardless of its retention\\\\n period or date.\\\\n\\\\n Default value: false\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the VSAM cluster\\\\n permanently.\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the VSAM data set named 'ibmuser.cntl.vsam':\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -f\\\\n\\\\n - Quietly delete all VSAM data sets that match\\\\n 'ibmuser.AAA.**.FFF' ignoring not-found errors:\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.AAA.**.FFF\\\\\\" -f\\\\n\\\\n - Delete a non-expired VSAM data set named\\\\n 'ibmuser.cntl.vsam':\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -f --purge\\\\n\\\\n - Delete an expired VSAM data set named 'ibmuser.cntl.vsam'\\\\n by overwriting the components with zeros:\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -f --erase\\\\n\\\\n - Quietly delete all VSAM data sets that match\\\\n 'ibmuser.AAA.**.FFF' ignoring not-found errors:\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -fi\\\\n\\\\n\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n data-set-vsam | vsam\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a VSAM cluster permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete data-set-vsam [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n dataSetName\\\\t\\\\t (string)\\\\n\\\\n The name of the VSAM cluster that you want to delete\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --erase | -e (boolean)\\\\n\\\\n Specify this option to overwrite the data component for the cluster with binary\\\\n zeros. This option is ignored if the NOERASE attribute was specified when the\\\\n cluster was defined or altered.\\\\n\\\\n Default value: false\\\\n\\\\n --purge | -p (boolean)\\\\n\\\\n Specify this option to delete the VSAM cluster regardless of its retention\\\\n period or date.\\\\n\\\\n Default value: false\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the VSAM cluster\\\\n permanently.\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the VSAM data set named 'ibmuser.cntl.vsam':\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -f\\\\n\\\\n - Delete all expired VSAM data sets that match\\\\n 'ibmuser.AAA.**.FFF':\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.AAA.**.FFF\\\\\\" -f\\\\n\\\\n - Delete a non-expired VSAM data set named\\\\n 'ibmuser.cntl.vsam':\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -f --purge\\\\n\\\\n - Delete an expired VSAM data set named 'ibmuser.cntl.vsam'\\\\n by overwriting the components with zeros:\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -f --erase\\\\n\\\\n\\" + \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n data-set-vsam | vsam\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a VSAM cluster permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete data-set-vsam [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n dataSetName\\\\t\\\\t (string)\\\\n\\\\n The name of the VSAM cluster that you want to delete\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --erase | -e (boolean)\\\\n\\\\n Specify this option to overwrite the data component for the cluster with binary\\\\n zeros. This option is ignored if the NOERASE attribute was specified when the\\\\n cluster was defined or altered.\\\\n\\\\n Default value: false\\\\n\\\\n --ignore-not-found | -i | --inf (boolean)\\\\n\\\\n Suppress errors if the VSAM data set does not exist.\\\\n\\\\n --purge | -p (boolean)\\\\n\\\\n Specify this option to delete the VSAM cluster regardless of its retention\\\\n period or date.\\\\n\\\\n Default value: false\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the VSAM cluster\\\\n permanently.\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the VSAM data set named 'ibmuser.cntl.vsam':\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -f\\\\n\\\\n - Quietly delete all VSAM data sets that match\\\\n 'ibmuser.AAA.**.FFF' ignoring not-found errors:\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.AAA.**.FFF\\\\\\" -f\\\\n\\\\n - Delete a non-expired VSAM data set named\\\\n 'ibmuser.cntl.vsam':\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -f --purge\\\\n\\\\n - Delete an expired VSAM data set named 'ibmuser.cntl.vsam'\\\\n by overwriting the components with zeros:\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -f --erase\\\\n\\\\n - Quietly delete all VSAM data sets that match\\\\n 'ibmuser.AAA.**.FFF' ignoring not-found errors:\\\\n\\\\n $ zowe zos-files delete data-set-vsam \\\\\\"ibmuser.cntl.vsam\\\\\\" -fi\\\\n\\\\n\\" }" `; diff --git a/packages/cli/__tests__/zosfiles/__integration__/delete/zfs/__snapshots__/cli.files.delete.zfs.integration.test.ts.snap b/packages/cli/__tests__/zosfiles/__integration__/delete/zfs/__snapshots__/cli.files.delete.zfs.integration.test.ts.snap index 19024a86ac..4cccd45874 100644 --- a/packages/cli/__tests__/zosfiles/__integration__/delete/zfs/__snapshots__/cli.files.delete.zfs.integration.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__integration__/delete/zfs/__snapshots__/cli.files.delete.zfs.integration.test.ts.snap @@ -32,6 +32,19 @@ exports[`Delete z/OS File System should display delete zfs help 1`] = ` Specify this option to confirm that you want to delete the ZFS permanently. + OPTIONS + ------- + + --ignore-not-found | -i | --inf (boolean) + + Suppress errors if the z/OS file does not exist. + + --response-timeout | --rto (number) + + The maximum amount of time in seconds the z/OSMF Files TSO servlet should run + before returning a response. Any request exceeding this amount of time will be + terminated and return an error. Allowed values: 5 - 600 + ZOSMF CONNECTION OPTIONS ------------------------ @@ -80,15 +93,6 @@ exports[`Delete z/OS File System should display delete zfs help 1`] = ` The file path to a certificate key file to use for authentication - OPTIONS - ------- - - --response-timeout | --rto (number) - - The maximum amount of time in seconds the z/OSMF Files TSO servlet should run - before returning a response. Any request exceeding this amount of time will be - terminated and return an error. Allowed values: 5 - 600 - PROFILE OPTIONS --------------- @@ -138,13 +142,18 @@ exports[`Delete z/OS File System should display delete zfs help 1`] = ` $ zowe zos-files delete zos-file-system \\"HLQ.MYNEW.ZFS\\" -f + - Quietly delete a z/OS file, suppressing errors if the file + doesn't exist: + + $ zowe zos-files delete zos-file-system \\"HLQ.MYNEW.ZFS\\" -fi + ================Z/OS FILES DELETE HELP WITH RFJ=========== { \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: zos-file-system.\\", - \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n zos-file-system | zfs\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a z/OS file system permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete zos-file-system [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n fileSystemName\\\\t\\\\t (string)\\\\n\\\\n The name of the z/OS file system that you want to delete.\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the ZFS permanently.\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the z/OS file system 'HLQ.MYNEW.ZFS':\\\\n\\\\n $ zowe zos-files delete zos-file-system \\\\\\"HLQ.MYNEW.ZFS\\\\\\" -f\\\\n\\\\n\\", + \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n zos-file-system | zfs\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a z/OS file system permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete zos-file-system [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n fileSystemName\\\\t\\\\t (string)\\\\n\\\\n The name of the z/OS file system that you want to delete.\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the ZFS permanently.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --ignore-not-found | -i | --inf (boolean)\\\\n\\\\n Suppress errors if the z/OS file does not exist.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the z/OS file system 'HLQ.MYNEW.ZFS':\\\\n\\\\n $ zowe zos-files delete zos-file-system \\\\\\"HLQ.MYNEW.ZFS\\\\\\" -f\\\\n\\\\n - Quietly delete a z/OS file, suppressing errors if the file\\\\n doesn't exist:\\\\n\\\\n $ zowe zos-files delete zos-file-system \\\\\\"HLQ.MYNEW.ZFS\\\\\\" -fi\\\\n\\\\n\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n zos-file-system | zfs\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a z/OS file system permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete zos-file-system [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n fileSystemName\\\\t\\\\t (string)\\\\n\\\\n The name of the z/OS file system that you want to delete.\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the ZFS permanently.\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the z/OS file system 'HLQ.MYNEW.ZFS':\\\\n\\\\n $ zowe zos-files delete zos-file-system \\\\\\"HLQ.MYNEW.ZFS\\\\\\" -f\\\\n\\\\n\\" + \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n zos-file-system | zfs\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Delete a z/OS file system permanently.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files delete zos-file-system [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n fileSystemName\\\\t\\\\t (string)\\\\n\\\\n The name of the z/OS file system that you want to delete.\\\\n\\\\n REQUIRED OPTIONS\\\\n ----------------\\\\n\\\\n --for-sure | -f (boolean)\\\\n\\\\n Specify this option to confirm that you want to delete the ZFS permanently.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --ignore-not-found | -i | --inf (boolean)\\\\n\\\\n Suppress errors if the z/OS file does not exist.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Delete the z/OS file system 'HLQ.MYNEW.ZFS':\\\\n\\\\n $ zowe zos-files delete zos-file-system \\\\\\"HLQ.MYNEW.ZFS\\\\\\" -f\\\\n\\\\n - Quietly delete a z/OS file, suppressing errors if the file\\\\n doesn't exist:\\\\n\\\\n $ zowe zos-files delete zos-file-system \\\\\\"HLQ.MYNEW.ZFS\\\\\\" -fi\\\\n\\\\n\\" }" `; diff --git a/packages/cli/__tests__/zosfiles/__integration__/upload/dtu/cli.files.upload.dtu.integration.test.ts b/packages/cli/__tests__/zosfiles/__integration__/upload/dtu/cli.files.upload.dtu.integration.test.ts index cc7ac1d335..8221c6b266 100644 --- a/packages/cli/__tests__/zosfiles/__integration__/upload/dtu/cli.files.upload.dtu.integration.test.ts +++ b/packages/cli/__tests__/zosfiles/__integration__/upload/dtu/cli.files.upload.dtu.integration.test.ts @@ -59,7 +59,7 @@ describe("Upload local dir to uss dir", () => { expect(response.stderr.toString()).toContain("USSDir"); }); - it("should fail when local directory does not exist", async () => { + it("should fail when local directory does not exist and no --inf flag", async () => { const shellScript = path.join(__dirname, "__scripts__", "command", "command_upload_dtu.sh"); const response = runCliScript(shellScript, TEST_ENVIRONMENT, ["localDirThatDoesNotExist", "/a/uss/dir"]); expect(stripNewLines(response.stderr.toString())).toContain("no such file or directory"); diff --git a/packages/cli/__tests__/zosfiles/__system__/delete/ds/cli.files.delete.ds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/delete/ds/cli.files.delete.ds.system.test.ts index 19a5dd259b..73a324098a 100644 --- a/packages/cli/__tests__/zosfiles/__system__/delete/ds/cli.files.delete.ds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/delete/ds/cli.files.delete.ds.system.test.ts @@ -137,6 +137,22 @@ describe("Delete Data Set", () => { runCliScript(__dirname + "/__scripts__/command/command_delete_data_set.sh", TEST_ENVIRONMENT, [dsname, "--for-sure", "--rfj"]); }); + + it("should delete a data set with --ignore-not-found flag", async () => { + const createResponse = runCliScript(__dirname + '/__scripts__/command/command_create_data_set.sh', + TEST_ENVIRONMENT, [dsname]); + expect(createResponse.status).toBe(0); // Ensure data set is created successfully + + // Now delete the data set, verify no output in ignore-not-found mode + const deleteResponse = runCliScript(__dirname + "/__scripts__/command/command_delete_data_set.sh", + TEST_ENVIRONMENT, [dsname, "--for-sure", "--ignore-not-found"]); + expect(deleteResponse.stderr.toString()).toBe(""); + + //delete again + const secondDelete = runCliScript(__dirname + "/__scripts__/command/command_delete_data_set.sh", + TEST_ENVIRONMENT, [dsname, "--for-sure", "--ignore-not-found"]); + expect(secondDelete.stderr.toString()).toBe(""); + }); }); describe("Expected failures", () => { diff --git a/packages/cli/__tests__/zosfiles/__system__/delete/uss/__snapshots__/cli.files.delete.file.system.test.ts.snap b/packages/cli/__tests__/zosfiles/__system__/delete/uss/__snapshots__/cli.files.delete.file.system.test.ts.snap index 5be159e14d..95488881e5 100644 --- a/packages/cli/__tests__/zosfiles/__system__/delete/uss/__snapshots__/cli.files.delete.file.system.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__system__/delete/uss/__snapshots__/cli.files.delete.file.system.test.ts.snap @@ -17,6 +17,12 @@ USS File or directory deleted successfully. " `; +exports[`Delete File Success scenarios should delete a file with --ignore-not-found flag 1`] = ` +"================Z/OS FILES DELETE FILE=============== +USS File or directory deleted successfully. +" +`; + exports[`Delete File Success scenarios should delete a file with response timeout 1`] = ` "================Z/OS FILES DELETE FILE=============== USS File or directory deleted successfully. diff --git a/packages/cli/__tests__/zosfiles/__system__/delete/uss/cli.files.delete.file.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/delete/uss/cli.files.delete.file.system.test.ts index 7b01434797..4ec2d2f2df 100644 --- a/packages/cli/__tests__/zosfiles/__system__/delete/uss/cli.files.delete.file.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/delete/uss/cli.files.delete.file.system.test.ts @@ -123,6 +123,7 @@ describe("Delete File", () => { expect(response.status).toBe(0); expect(response.stdout.toString()).toMatchSnapshot(); }); + it("should delete a file with response timeout", async () => { const response = runCliScript(__dirname + "/__scripts__/command/command_delete_file.sh", TEST_ENVIRONMENT, [ussname, "--for-sure", "--responseTimeout 5"]); @@ -130,6 +131,20 @@ describe("Delete File", () => { expect(response.status).toBe(0); expect(response.stdout.toString()).toMatchSnapshot(); }); + + it("should delete a file with --ignore-not-found flag", async () => { + const response = runCliScript(__dirname + "/__scripts__/command/command_delete_file.sh", + TEST_ENVIRONMENT, [ussname, "--for-sure", "--ignore-not-found"]); + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toMatchSnapshot(); + + //delete this file a second time, it doesnt exist. ensure no output because --inf + const secondResponse = runCliScript(__dirname + "/__scripts__/command/command_delete_file.sh", + TEST_ENVIRONMENT, [ussname, "--for-sure", "--ignore-not-found"]); + expect(secondResponse.stderr.toString()).toBe(""); + expect(secondResponse.status).toBe(0); + }); }); describe("Expected failures", () => { diff --git a/packages/cli/__tests__/zosfiles/__system__/delete/vsam/__snapshots__/cli.files.delete.vsam.system.test.ts.snap b/packages/cli/__tests__/zosfiles/__system__/delete/vsam/__snapshots__/cli.files.delete.vsam.system.test.ts.snap index d632dd27ac..134895c2db 100644 --- a/packages/cli/__tests__/zosfiles/__system__/delete/vsam/__snapshots__/cli.files.delete.vsam.system.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__system__/delete/vsam/__snapshots__/cli.files.delete.vsam.system.test.ts.snap @@ -18,6 +18,12 @@ Data set deleted successfully. " `; +exports[`Delete VSAM Data Set Success scenarios should successfully delete a VSAM data set with --ignore-not-found flag 1`] = ` +"================Z/OS FILES DELETE VSAM DATA SET=============== +Data set deleted successfully. +" +`; + exports[`Delete VSAM Data Set without profiles should delete a data set 1`] = ` "Data set deleted successfully. " diff --git a/packages/cli/__tests__/zosfiles/__system__/delete/vsam/cli.files.delete.vsam.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/delete/vsam/cli.files.delete.vsam.system.test.ts index b8207771b7..83c4d3847e 100644 --- a/packages/cli/__tests__/zosfiles/__system__/delete/vsam/cli.files.delete.vsam.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/delete/vsam/cli.files.delete.vsam.system.test.ts @@ -128,6 +128,26 @@ describe("Delete VSAM Data Set", () => { expect(response.status).toBe(0); expect(response.stdout.toString()).toMatchSnapshot(); }); + + it("should successfully delete a VSAM data set with --ignore-not-found flag", async () => { + // create vsam + const createResponse = runCliScript(__dirname + "/__scripts__/command/command_invoke_ams_define_statement.sh", + TEST_ENVIRONMENT, [dsname, volume]); + expect(createResponse.status).toBe(0); + + // now delete + const deleteResponse = runCliScript(__dirname + "/__scripts__/command/command_delete_vsam_data_set.sh", + TEST_ENVIRONMENT, [dsname, "--for-sure", "--ignore-not-found"]); + expect(deleteResponse.stderr.toString()).toBe(""); + expect(deleteResponse.status).toBe(0); + expect(deleteResponse.stdout.toString()).toMatchSnapshot(); + + //repeat and ensure no error + const repeatDelete = runCliScript(__dirname + "/__scripts__/command/command_delete_vsam_data_set.sh", + TEST_ENVIRONMENT, [dsname, "--for-sure", "--ignore-not-found"]); + expect(repeatDelete.stderr.toString()).toBe(""); + expect(repeatDelete.status).toBe(0); + }); }); describe("Expected failures", () => { @@ -137,6 +157,15 @@ describe("Delete VSAM Data Set", () => { expect(response.status).toBe(1); expect(stripNewLines(response.stderr.toString())).toContain(`ENTRY ${user}.DOES.NOT.EXIST NOT DELETED`); }); + it("should fail deleting a non-existent data set without a --ignore-not-found flag", async () => { + // Attempt to delete a non-existent VSAM dataset without the --ignore-not-found flag + const response = runCliScript(__dirname + "/__scripts__/command/command_delete_vsam_data_set.sh", + TEST_ENVIRONMENT, [user + ".DOES.NOT.EXIST", "--for-sure"]); + + // Check that stderr contains the expected error message about the dataset not being found + expect(response.status).toBe(1); + expect(stripNewLines(response.stderr.toString())).toContain(`ENTRY ${user}.DOES.NOT.EXIST NOT FOUND`); + }); it("should fail due to retention period not being exceeded", async () => { let response = runCliScript(__dirname + "/__scripts__/command/command_invoke_ams_define_for_statement.sh", diff --git a/packages/cli/__tests__/zosfiles/__system__/delete/zfs/__snapshots__/cli.files.delete.zfs.system.test.ts.snap b/packages/cli/__tests__/zosfiles/__system__/delete/zfs/__snapshots__/cli.files.delete.zfs.system.test.ts.snap index d094e601e6..dab29e2f46 100644 --- a/packages/cli/__tests__/zosfiles/__system__/delete/zfs/__snapshots__/cli.files.delete.zfs.system.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__system__/delete/zfs/__snapshots__/cli.files.delete.zfs.system.test.ts.snap @@ -6,6 +6,12 @@ z/OS file system deleted successfully. " `; +exports[`Delete z/OS File System Success scenarios should delete a ZFS with --ignore-not-found flag 1`] = ` +"================Z/OS FILES DELETE Z/OS FILE SYSTEM=============== +z/OS file system deleted successfully. +" +`; + exports[`Delete z/OS File System Success scenarios should delete a ZFS with response timeout 1`] = ` "================Z/OS FILES DELETE Z/OS FILE SYSTEM=============== z/OS file system deleted successfully. diff --git a/packages/cli/__tests__/zosfiles/__system__/delete/zfs/cli.files.delete.zfs.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/delete/zfs/cli.files.delete.zfs.system.test.ts index a8df1eed3e..e389c489a8 100644 --- a/packages/cli/__tests__/zosfiles/__system__/delete/zfs/cli.files.delete.zfs.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/delete/zfs/cli.files.delete.zfs.system.test.ts @@ -103,6 +103,7 @@ describe("Delete z/OS File System", () => { expect(response.status).toBe(0); expect(response.stdout.toString()).toMatchSnapshot(); }); + it("should delete a ZFS with response timeout", async () => { let response = runCliScript(__dirname + "/__scripts__/command/command_create_zfs.sh", TEST_ENVIRONMENT, [fsname, volume, "--responseTimeout 5"]); @@ -114,6 +115,26 @@ describe("Delete z/OS File System", () => { expect(response.status).toBe(0); expect(response.stdout.toString()).toMatchSnapshot(); }); + + it("should delete a ZFS with --ignore-not-found flag", async () => { + // first create zfs + const createResponse = runCliScript(__dirname + "/__scripts__/command/command_create_zfs.sh", + TEST_ENVIRONMENT, [fsname, volume]); + expect(createResponse.status).toBe(0); + + const deleteResponse = runCliScript(__dirname + "/__scripts__/command/command_delete_zfs.sh", + TEST_ENVIRONMENT, [fsname, "--for-sure", "--ignore-not-found"]); + expect(deleteResponse.stderr.toString()).toBe(""); + expect(deleteResponse.status).toBe(0); + expect(deleteResponse.stdout.toString()).toMatchSnapshot(); + + //repeat and ensure still no output because --inf + const deleteResp = runCliScript(__dirname + "/__scripts__/command/command_delete_zfs.sh", + TEST_ENVIRONMENT, [fsname, "--for-sure", "--ignore-not-found"]); + expect(deleteResp.stderr.toString()).toBe(""); + expect(deleteResp.status).toBe(0); + }); + }); describe("Expected failures", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/create/vsam/Vsam.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/create/vsam/Vsam.handler.unit.test.ts index cdcdf06c1d..667903a29a 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/create/vsam/Vsam.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/create/vsam/Vsam.handler.unit.test.ts @@ -16,6 +16,10 @@ import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src_ const message: string = "Dummy error message"; describe("Create VSAM data set handler", () => { + beforeEach(() => { + jest.clearAllMocks(); + Create.vsam = jest.fn(); // Ensure a fresh mock + }); describe("process method", () => { it("should create a VSAM data set if requested", async () => { // Require the handler and create a new instance @@ -84,61 +88,35 @@ describe("Create VSAM data set handler", () => { expect(logMessage).toMatchSnapshot(); }); }); - it("should raise an error", async () => { - // Require the handler and create a new instance const handlerReq = require("../../../../../src/zosfiles/create/vsam/vsam.handler"); const handler = new handlerReq.default(); const dataSetName = "testing"; - // Vars populated by the mocked function - let error: any; - let apiMessage = ""; - let jsonObj; - let logMessage = ""; - let fakeSession = null; + // Ensure the spy works as intended + const createVsamSpy = jest.spyOn(Create, "vsam"); - // Mock the vsam function - Create.vsam = jest.fn((session) => { - fakeSession = session; - const impErr = new ImperativeError({ - msg: message - }); - throw impErr; + createVsamSpy.mockImplementationOnce(() => { + throw new ImperativeError({ msg: message }); }); - try { - // Invoke the handler with a full set of mocked arguments and response functions - await handler.process({ + const commandParameters = { + arguments: { + dataSetName, + ...UNIT_TEST_ZOSMF_PROF_OPTS, + }, + response: { + data: { setObj: jest.fn() }, + console: { log: jest.fn() }, + progress: { endBar: jest.fn() } + }, + }; - arguments: { - $0: "fake", - _: ["fake"], - dataSetName, - ...UNIT_TEST_ZOSMF_PROF_OPTS - }, - response: { - data: { - setMessage: jest.fn((setMsgArgs) => { - apiMessage = setMsgArgs; - }), - setObj: jest.fn((setObjArgs) => { - jsonObj = setObjArgs; - }) - }, - console: { - log: jest.fn((logArgs) => { - logMessage += "\n" + logArgs; - }) - } - } - } as any); - } catch (e) { - error = e; - } + // Ensure the error is thrown as expected + await expect(handler.process(commandParameters)).rejects.toThrow(ImperativeError); - expect(error).toBeDefined(); - expect(Create.vsam).toHaveBeenCalledTimes(1); - expect(Create.vsam).toHaveBeenCalledWith(fakeSession, dataSetName, {}); + // Validate that the function was called correctly + expect(createVsamSpy).toHaveBeenCalledTimes(1); + expect(createVsamSpy).toHaveBeenCalledWith(expect.any(Object), dataSetName, {}); }); }); diff --git a/packages/cli/__tests__/zosfiles/__unit__/create/zfs/zfs.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/create/zfs/zfs.handler.unit.test.ts index d206a06c20..107cfdd8c0 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/create/zfs/zfs.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/create/zfs/zfs.handler.unit.test.ts @@ -107,32 +107,35 @@ describe("Create z/OS file system handler", () => { throw impErr; }); - try { - // Invoke the handler with a full set of mocked arguments and response functions - await handler.process({ - - arguments: { - $0: "fake", - _: ["fake"], - fileSystemName, - ...UNIT_TEST_ZOSMF_PROF_OPTS + const commandParameters = { + arguments: { + $0: "fake", + _: ["fake"], + fileSystemName, + ...UNIT_TEST_ZOSMF_PROF_OPTS, + }, + response: { + data: { + setMessage: jest.fn((setMsgArgs) => { + apiMessage = setMsgArgs; + }), + setObj: jest.fn((setObjArgs) => { + jsonObj = setObjArgs; + }), }, - response: { - data: { - setMessage: jest.fn((setMsgArgs) => { - apiMessage = setMsgArgs; - }), - setObj: jest.fn((setObjArgs) => { - jsonObj = setObjArgs; - }) - }, - console: { - log: jest.fn((logArgs) => { - logMessage += "\n" + logArgs; - }) - } - } - } as any); + console: { + log: jest.fn((logArgs) => { + logMessage += "\n" + logArgs; + }), + }, + progress: { + endBar: jest.fn(), // Mocking progress.endBar here + }, + }, + }; + + try { + await handler.process(commandParameters); } catch (e) { error = e; } diff --git a/packages/cli/__tests__/zosfiles/__unit__/delete/ds/Ds.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/delete/ds/Ds.handler.unit.test.ts index afcb28b0ae..9e157b4065 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/delete/ds/Ds.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/delete/ds/Ds.handler.unit.test.ts @@ -12,6 +12,7 @@ import { Delete, IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk"; import DsHandler from "../../../../../src/zosfiles/delete/ds/Ds.handler"; import { ZosFilesBaseHandler } from "../../../../../src/zosfiles/ZosFilesBase.handler"; +import { ImperativeError, ConnectionPropsForSessCfg } from "@zowe/imperative"; describe("DsHandler", () => { const defaultReturn: IZosFilesResponse = { @@ -19,9 +20,19 @@ describe("DsHandler", () => { commandResponse: "THIS IS A TEST" }; - const deleteDatasetSpy = jest.spyOn(Delete, "dataSet"); + const fileNotFoundError = new ImperativeError({ + msg: "IDC3012I ENTRY HLQ.MYNEW.DATASET NOT FOUND", + additionalDetails: "", + errorCode: '404' + }); + + let deleteDatasetSpy: any; beforeEach(() => { + jest.spyOn(ConnectionPropsForSessCfg, "addPropsOrPrompt").mockResolvedValue({ + hostname: "example.com" + }); + deleteDatasetSpy = jest.spyOn(Delete, "dataSet"); deleteDatasetSpy.mockClear(); deleteDatasetSpy.mockImplementation(async () => defaultReturn); }); @@ -80,4 +91,43 @@ describe("DsHandler", () => { ); expect(response).toBe(defaultReturn); }); + + it("should return success: true when --ignore-not-found () flag is used and dataset is not found", async () => { + deleteDatasetSpy.mockImplementation(() => { + throw fileNotFoundError; + }); + + const handler = new DsHandler(); + const commandParameters: any = { + arguments: { + dataSetName: "ABCD", + forSure: true, + ignoreNotFound: true, + }, + response: { + progress: { endBar: jest.fn() }, + data: { setObj: jest.fn() } + } + }; + + await expect(handler.process(commandParameters)).resolves.toBe(undefined); + }); + + it("should throw file not found error (404) when --ignore-not-found is not used", async () => { + deleteDatasetSpy.mockImplementation(() => { + throw fileNotFoundError; + }); + + const handler = new DsHandler(); + const commandParameters: any = { + arguments: { + dataSetName: "ABCD", + forSure: true + } + }; + + const error = new ImperativeError({ msg: "IDC3012I ENTRY HLQ.MYNEW.DATASET NOT FOUND" }); + + await expect(handler.processWithSession(commandParameters, {} as any)).rejects.toThrow(error); + }); }); diff --git a/packages/cli/__tests__/zosfiles/__unit__/delete/uss/Uss.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/delete/uss/Uss.handler.unit.test.ts index 6717502f6d..d11e8f0d90 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/delete/uss/Uss.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/delete/uss/Uss.handler.unit.test.ts @@ -11,23 +11,35 @@ import { Delete, IZosFilesResponse, IZosFilesOptions } from "@zowe/zos-files-for-zowe-sdk"; import UssHandler from "../../../../../src/zosfiles/delete/uss/Uss.handler"; +import { ImperativeError, ConnectionPropsForSessCfg } from "@zowe/imperative"; import { ZosFilesBaseHandler } from "../../../../../src/zosfiles/ZosFilesBase.handler"; + describe("UssHandler", () => { const defaultReturn: IZosFilesResponse = { success : true, commandResponse: "THIS IS A TEST" }; - const deleteUssFileSpy = jest.spyOn(Delete, "ussFile"); + const fileNotFoundError = new ImperativeError({ + msg: "IDC3012I ENTRY HLQ.MYNEW.FILE NOT FOUND", + additionalDetails: "", + errorCode: '404' + }); + + let deleteUssFileSpy: any; beforeEach(() => { + jest.spyOn(ConnectionPropsForSessCfg, "addPropsOrPrompt").mockResolvedValue({ + hostname: "example.com" + }); + deleteUssFileSpy = jest.spyOn(Delete, "ussFile"); deleteUssFileSpy.mockClear(); deleteUssFileSpy.mockImplementation(async () => defaultReturn); }); it("should call Delete.ussFile", async () => { const handler = new UssHandler(); - const zosFilesOptions: IZosFilesOptions = {responseTimeout: undefined}; + const zosFilesOptions: IZosFilesOptions = { responseTimeout: undefined }; expect(handler).toBeInstanceOf(ZosFilesBaseHandler); @@ -53,4 +65,42 @@ describe("UssHandler", () => { expect(response).toBe(defaultReturn); }); + it("should return success: true when --ignore-not-found flag is used and file is not found", async () => { + deleteUssFileSpy.mockImplementation(() => { + throw fileNotFoundError; + }); + + const handler = new UssHandler(); + const commandParameters: any = { + arguments: { + fileName: "ABCD", + forSure: true, + ignoreNotFound: true, + }, + response: { + progress: { endBar: jest.fn() }, + data: { setObj: jest.fn() } + } + }; + + await expect(handler.process(commandParameters)).resolves.toBe(undefined); + }); + + it("should throw file not found error (404) when --ignore-not-found is not used", async () => { + deleteUssFileSpy.mockImplementation(() => { + throw fileNotFoundError; + }); + + const handler = new UssHandler(); + const commandParameters: any = { + arguments: { + fileName: "ABCD", + forSure: true + } + }; + + const error = new ImperativeError({ msg: "IDC3012I ENTRY HLQ.MYNEW.FILE NOT FOUND" }); + + await expect(handler.processWithSession(commandParameters, {} as any)).rejects.toThrow(error); + }); }); diff --git a/packages/cli/__tests__/zosfiles/__unit__/delete/vsam/Vsam.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/delete/vsam/Vsam.handler.unit.test.ts index 1699fc3db2..1d147a1cac 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/delete/vsam/Vsam.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/delete/vsam/Vsam.handler.unit.test.ts @@ -11,6 +11,7 @@ import { Delete, IDeleteVsamResponse } from "@zowe/zos-files-for-zowe-sdk"; import VsamHandler from "../../../../../src/zosfiles/delete/vsam/Vsam.handler"; +import { ConnectionPropsForSessCfg, ImperativeError } from "@zowe/imperative"; import { ZosFilesBaseHandler } from "../../../../../src/zosfiles/ZosFilesBase.handler"; describe("VsamHandler", () => { @@ -20,9 +21,19 @@ describe("VsamHandler", () => { apiResponse : undefined as any }; - const deleteVsamDatasetSpy = jest.spyOn(Delete, "vsam"); + const fileNotFoundError = new ImperativeError({ + msg: "IDC3012I ENTRY HLQ.MYNEW.VSAM NOT FOUND", + additionalDetails: "", + errorCode: '404' + }); + + let deleteVsamDatasetSpy: any; beforeEach(() => { + jest.spyOn(ConnectionPropsForSessCfg, "addPropsOrPrompt").mockResolvedValue({ + hostname: "example.com" + }); + deleteVsamDatasetSpy = jest.spyOn(Delete, "vsam"); deleteVsamDatasetSpy.mockClear(); deleteVsamDatasetSpy.mockImplementation(async () => defaultReturn); }); @@ -57,4 +68,45 @@ describe("VsamHandler", () => { ); expect(response).toBe(defaultReturn); }); + + it("should return success: true when --ignore-not-found flag is used and file is not found", async () => { + deleteVsamDatasetSpy.mockImplementationOnce(() => { + throw fileNotFoundError; + }); + + const handler = new VsamHandler(); + const commandParameters: any = { + arguments: { + dataSetName: "ABCD", + erase: true, + purge: false, + forSure: true, + ignoreNotFound: true, + } + }; + + const response = await handler.processWithSession(commandParameters, {} as any); + expect(response).toHaveProperty('success', true); + expect(deleteVsamDatasetSpy).toHaveBeenCalledTimes(1); + }); + + it("should throw file not found error (404) when --ignore-not-found is not used", async () => { + deleteVsamDatasetSpy.mockImplementationOnce(() => { + throw fileNotFoundError; + }); + + const handler = new VsamHandler(); + const commandParameters: any = { + arguments: { + dataSetName: "ABCD", + erase: true, + forSure: true, + purge: false + } + }; + + await expect(handler.processWithSession(commandParameters, {} as any)).rejects.toThrow( + new ImperativeError({ msg: "IDC3012I ENTRY HLQ.MYNEW.VSAM NOT FOUND" }) + ); + }); }); diff --git a/packages/cli/__tests__/zosfiles/__unit__/delete/zfs/__snapshots__/zfs.definition.unit.test.ts.snap b/packages/cli/__tests__/zosfiles/__unit__/delete/zfs/__snapshots__/zfs.definition.unit.test.ts.snap index 650fb3399c..d3640cd244 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/delete/zfs/__snapshots__/zfs.definition.unit.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__unit__/delete/zfs/__snapshots__/zfs.definition.unit.test.ts.snap @@ -11,6 +11,16 @@ Array [ "required": true, "type": "boolean", }, + Object { + "aliases": Array [ + "i", + "inf", + ], + "description": "Suppress errors if the z/OS file does not exist.", + "name": "ignore-not-found", + "required": false, + "type": "boolean", + }, ] `; @@ -20,5 +30,9 @@ Array [ "description": "Delete the z/OS file system 'HLQ.MYNEW.ZFS'", "options": "\\"HLQ.MYNEW.ZFS\\" -f", }, + Object { + "description": "Quietly delete a z/OS file, suppressing errors if the file doesn't exist", + "options": "\\"HLQ.MYNEW.ZFS\\" -fi", + }, ] `; diff --git a/packages/cli/__tests__/zosfiles/__unit__/delete/zfs/zfs.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/delete/zfs/zfs.handler.unit.test.ts index b5b6f1f549..e30635edc7 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/delete/zfs/zfs.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/delete/zfs/zfs.handler.unit.test.ts @@ -12,18 +12,29 @@ import { Delete, IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk"; import ZfsHandler from "../../../../../src/zosfiles/delete/zfs/zfs.handler"; import { ZosFilesBaseHandler } from "../../../../../src/zosfiles/ZosFilesBase.handler"; +import { ImperativeError, ConnectionPropsForSessCfg } from "@zowe/imperative"; describe("ZfsHandler", () => { const defaultReturn: IZosFilesResponse = { - success : true, - commandResponse: "THIS IS A TEST" + success: true, + commandResponse: "THIS IS A TEST", }; - const deleteZfs = jest.spyOn(Delete, "zfs"); + const fileNotFoundError = new ImperativeError({ + msg: "IDC3012I ENTRY HLQ.MYNEW.ZFS NOT FOUND", + additionalDetails: "", + errorCode: '404' + }); + + let deleteZfsSpy: any; beforeEach(() => { - deleteZfs.mockClear(); - deleteZfs.mockImplementation(async () => defaultReturn); + jest.spyOn(ConnectionPropsForSessCfg, "addPropsOrPrompt").mockResolvedValue({ + hostname: "example.com" + }); + deleteZfsSpy = jest.spyOn(Delete, "zfs"); + deleteZfsSpy.mockClear(); + deleteZfsSpy.mockImplementationOnce(async () => defaultReturn); }); it("should call Delete.zfs", async () => { @@ -41,16 +52,55 @@ describe("ZfsHandler", () => { const dummySession = { lazyness: "(n.) An important quality for a developer to have." }; // I'm lazy and we don't actually need the object - const rtoObject = {responseTimeout: 5}; + const rtoObject = { responseTimeout: 5 }; const response = await handler.processWithSession(commandParameters, dummySession as any); - expect(deleteZfs).toHaveBeenCalledTimes(1); - expect(deleteZfs).toHaveBeenLastCalledWith( + expect(deleteZfsSpy).toHaveBeenCalledTimes(1); + expect(deleteZfsSpy).toHaveBeenLastCalledWith( dummySession, commandParameters.arguments.fileSystemName, rtoObject ); expect(response).toBe(defaultReturn); }); + + it("should return success: true when --ignore-not-found flag is used and file is not found", async () => { + deleteZfsSpy.mockImplementationOnce(() => { + throw fileNotFoundError; + }); + + const handler = new ZfsHandler(); + const commandParameters: any = { + arguments: { + fileSystemName: "ABCD", + forSure: true, + ignoreNotFound: true, + }, + response: { + progress: { endBar: jest.fn() }, + data: { setObj: jest.fn() } + } + }; + + await expect(handler.processWithSession(commandParameters, {} as any)).resolves.toBeTruthy(); + }); + + it("should throw file not found error (404) when --ignore-not-found is not used", async () => { + deleteZfsSpy.mockImplementation(() => { + throw fileNotFoundError; + }); + + const handler = new ZfsHandler(); + const commandParameters: any = { + arguments: { + fileSystemName: "ABCD", + forSure: true // --forSure flag, no --ignore-not-found flag + } + }; + + const error = new ImperativeError({ msg: "IDC3012I ENTRY HLQ.MYNEW.ZFS NOT FOUND" }); + + await expect(handler.processWithSession(commandParameters, {} as any)).rejects.toThrow(error); + }); }); diff --git a/packages/cli/__tests__/zosfiles/__unit__/download/dsm/DataSetMatching.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/download/dsm/DataSetMatching.handler.unit.test.ts index ce1ae9cb95..7b272260fd 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/download/dsm/DataSetMatching.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/download/dsm/DataSetMatching.handler.unit.test.ts @@ -204,4 +204,4 @@ describe("Download DataSetMatching handler", () => { expect(List.dataSetsMatchingPattern).toHaveBeenCalledWith(passedSession, [pattern], { ...fakeListOptions }); expect(Download.allDataSets).toHaveBeenCalledTimes(0); }); -}); +}); \ No newline at end of file diff --git a/packages/cli/__tests__/zosfiles/__unit__/mount/fs/fs.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/mount/fs/fs.handler.unit.test.ts index 2a4fdee14a..51a9c91f63 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/mount/fs/fs.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/mount/fs/fs.handler.unit.test.ts @@ -145,4 +145,4 @@ describe("Mount file system handler", () => { expect(Mount.fs).toHaveBeenCalledTimes(1); expect(Mount.fs).toHaveBeenCalledWith(fakeSession, fileSystemName, mountPoint, {}); }); -}); +}); \ No newline at end of file diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/FileToDataSet.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/FileToDataSet.handler.unit.test.ts index c71ada1d52..9a16cacf1a 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/FileToDataSet.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/FileToDataSet.handler.unit.test.ts @@ -273,7 +273,7 @@ describe("Upload file-to-data-set handler", () => { fakeSession = session; return { success: false, - commandResponse: "uploaded", + commandResponse: "upload failed", apiResponse: [ {success: false, from: inputfile, to: dataSetName} ] @@ -318,7 +318,7 @@ describe("Upload file-to-data-set handler", () => { } expect(error).toBeDefined(); - expect(error.message).toBe("uploaded"); + expect(error.message).toBe("upload failed"); expect(Upload.fileToDataset).toHaveBeenCalledTimes(1); expect(Upload.fileToDataset).toHaveBeenCalledWith(fakeSession, inputfile, dataSetName, { binary: undefined, @@ -337,7 +337,7 @@ describe("Upload file-to-data-set handler", () => { expect(logMessage).toMatch(/success:.*0/); expect(logMessage).toMatch(/error:.*1/); expect(logMessage).toMatch(/skipped:.*0/); - expect(logMessage).toMatch(/uploaded/); + expect(error.mDetails.msg).toContain('upload failed'); }); }); }); diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/__snapshots__/FileToDataSet.handler.unit.test.ts.snap b/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/__snapshots__/FileToDataSet.handler.unit.test.ts.snap index 1cd2b1490a..71449a6dff 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/__snapshots__/FileToDataSet.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/__snapshots__/FileToDataSet.handler.unit.test.ts.snap @@ -9,7 +9,7 @@ Object { "to": "testing", }, ], - "commandResponse": "uploaded", + "commandResponse": "upload failed", "success": false, } `; diff --git a/packages/cli/src/zosfiles/-strings-/en.ts b/packages/cli/src/zosfiles/-strings-/en.ts index c84853506e..30be983c42 100644 --- a/packages/cli/src/zosfiles/-strings-/en.ts +++ b/packages/cli/src/zosfiles/-strings-/en.ts @@ -251,11 +251,13 @@ export default { OPTIONS: { VOLUME: "The volume serial (VOLSER) where the data set resides. The option is required only when the data set is not" + " catalogued on the system.", - FOR_SURE: "Specify this option to confirm that you want to delete the data set permanently." + FOR_SURE: "Specify this option to confirm that you want to delete the data set permanently.", + IGNORE_NF: "Suppress errors if the data set does not exist." }, EXAMPLES: { EX1: "Delete the data set named 'ibmuser.cntl'", - EX2: "Delete the data set member named 'ibmuser.cntl(mem)'" + EX2: "Delete the data set member named 'ibmuser.cntl(mem)'", + EX3: "Quietly delete a data set, suppressing errors if it doesn't exist" } }, MIGRATED_DATA_SET: { @@ -283,13 +285,15 @@ export default { FOR_SURE: "Specify this option to confirm that you want to delete the VSAM cluster permanently.", ERASE: "Specify this option to overwrite the data component for the cluster with binary zeros. This " + "option is ignored if the NOERASE attribute was specified when the cluster was defined or altered.", - PURGE: "Specify this option to delete the VSAM cluster regardless of its retention period or date." + PURGE: "Specify this option to delete the VSAM cluster regardless of its retention period or date.", + IGNORE_NF: "Suppress errors if the VSAM data set does not exist." }, EXAMPLES: { EX1: "Delete the VSAM data set named 'ibmuser.cntl.vsam'", - EX2: "Delete all expired VSAM data sets that match 'ibmuser.AAA.**.FFF'", + EX2: "Quietly delete all VSAM data sets that match 'ibmuser.AAA.**.FFF' ignoring not-found errors", EX3: "Delete a non-expired VSAM data set named 'ibmuser.cntl.vsam'", - EX4: "Delete an expired VSAM data set named 'ibmuser.cntl.vsam' by overwriting the components with zeros" + EX4: "Delete an expired VSAM data set named 'ibmuser.cntl.vsam' by overwriting the components with zeros", + EX5: "Quietly delete VSAM data set, suppressing errors if it doesn't exist" } }, USS: { @@ -300,12 +304,14 @@ export default { }, OPTIONS: { FOR_SURE: "Specify this option to confirm that you want to delete the file or directory permanently.", - RECURSIVE: "Delete directories recursively." + RECURSIVE: "Delete directories recursively.", + IGNORE_NF: "Suppress errors if the file does not exist." }, EXAMPLES: { EX1: "Delete the empty directory '/u/ibmuser/testcases'", EX2: "Delete the file named '/a/ibmuser/my_text.txt'", - EX3: "Recursively delete the directory named '/u/ibmuser/testcases'" + EX3: "Recursively delete the directory named '/u/ibmuser/testcases'", + EX4: "Quietly delete a file, suppressing errors if the file doesn't exist" } }, ZFS: { @@ -315,10 +321,14 @@ export default { FILESYSTEMNAME: "The name of the z/OS file system that you want to delete." }, OPTIONS: { - FOR_SURE: "Specify this option to confirm that you want to delete the ZFS permanently." + FOR_SURE: "Specify this option to confirm that you want to delete the ZFS permanently.", + IGNORE_NF: "Suppress errors if the z/OS file does not exist." + }, EXAMPLES: { - EX1: "Delete the z/OS file system 'HLQ.MYNEW.ZFS'" + EX1: "Delete the z/OS file system 'HLQ.MYNEW.ZFS'", + EX2: "Quietly delete a z/OS file, suppressing errors if the file doesn't exist" + } } } diff --git a/packages/cli/src/zosfiles/ZosFilesBase.handler.ts b/packages/cli/src/zosfiles/ZosFilesBase.handler.ts index 5ccca6bd67..9eb1222f8a 100644 --- a/packages/cli/src/zosfiles/ZosFilesBase.handler.ts +++ b/packages/cli/src/zosfiles/ZosFilesBase.handler.ts @@ -39,33 +39,44 @@ export abstract class ZosFilesBaseHandler implements ICommandHandler { * * @returns {Promise} */ - public async process(commandParameters: IHandlerParameters) { - const sessCfg: ISession = ZosmfSession.createSessCfgFromArgs( - commandParameters.arguments - ); - const sessCfgWithCreds = await ConnectionPropsForSessCfg.addPropsOrPrompt( - sessCfg, commandParameters.arguments, {parms: commandParameters} - ); - - const session = new Session(sessCfgWithCreds); - const response = await this.processWithSession(commandParameters, session); - - commandParameters.response.progress.endBar(); // end any progress bars - // Print out the response - if (response.commandResponse) { - commandParameters.response.console.log(response.commandResponse); - } - - // Return as an object when using --response-format-json - commandParameters.response.data.setObj(response); - - // Ensure error gets thrown if request was unsuccessful. - // Sometimes it is useful to delay throwing an error until the end of the handler is - // reached, for example the upload API needs to return an API response even when it fails. - if (!response.success && response.commandResponse) { - throw new ImperativeError({ - msg: response.errorMessage || response.commandResponse - }); + public async process(commandParameters: IHandlerParameters): Promise { + try { + const sessCfg: ISession = ZosmfSession.createSessCfgFromArgs( + commandParameters.arguments + ); + const sessCfgWithCreds = await ConnectionPropsForSessCfg.addPropsOrPrompt( + sessCfg, commandParameters.arguments, { parms: commandParameters } + ); + const session = new Session(sessCfgWithCreds); + const response = await this.processWithSession(commandParameters, session); + + commandParameters.response.progress.endBar(); + if (response.commandResponse) { + commandParameters.response.console.log(response.commandResponse); + } + // Return as an object when using --response-format-json + commandParameters.response.data.setObj(response); + + // Ensure error gets thrown if request was unsuccessful. + // Sometimes it is useful to delay throwing an error until the end of the handler is + // reached, for example the upload API needs to return an API response even when it fails. + if (!response.success && response.commandResponse) { + throw new ImperativeError({ + msg: response.errorMessage || response.commandResponse + }); + } + } catch (error) { + if (commandParameters.arguments.ignoreNotFound && error.errorCode == '404') { + commandParameters.response.data.setObj({ success: true }); + } else { + if (error instanceof ImperativeError){ + throw error; + } + throw new ImperativeError({ + msg: error.message, + causeErrors: error + }); + } } } diff --git a/packages/cli/src/zosfiles/delete/ds/Ds.definition.ts b/packages/cli/src/zosfiles/delete/ds/Ds.definition.ts index 3d320054d6..806c6d5e35 100644 --- a/packages/cli/src/zosfiles/delete/ds/Ds.definition.ts +++ b/packages/cli/src/zosfiles/delete/ds/Ds.definition.ts @@ -53,6 +53,13 @@ export const DsDefinition: ICommandDefinition = { aliases: ["vol"], description: strings.OPTIONS.VOLUME, type: "string" + }, + { + name: "ignore-not-found", + aliases: ["i", "inf"], + description: strings.OPTIONS.IGNORE_NF, + type: "boolean", + required: false } ] as ICommandOptionDefinition[]).sort((a, b) => a.name.localeCompare(b.name)), examples: [ @@ -63,6 +70,10 @@ export const DsDefinition: ICommandDefinition = { { description: strings.EXAMPLES.EX2, options: `"ibmuser.cntl(mem)" -f` + }, + { + description: strings.EXAMPLES.EX3, + options: `"ibmuser.cntl(mem)" -fi` } ] }; diff --git a/packages/cli/src/zosfiles/delete/uss/Uss.definition.ts b/packages/cli/src/zosfiles/delete/uss/Uss.definition.ts index 2a8f09ca3b..2f0bbd4de2 100644 --- a/packages/cli/src/zosfiles/delete/uss/Uss.definition.ts +++ b/packages/cli/src/zosfiles/delete/uss/Uss.definition.ts @@ -54,6 +54,13 @@ export const UssDefinition: ICommandDefinition = { description: strings.OPTIONS.RECURSIVE, type: "boolean", required: false + }, + { + name: "ignore-not-found", + aliases: ["i", "inf"], + description: strings.OPTIONS.IGNORE_NF, + type: "boolean", + required: false } ], examples: [ @@ -68,6 +75,10 @@ export const UssDefinition: ICommandDefinition = { { description: strings.EXAMPLES.EX3, options: `"/a/ibmuser/testcases" -rf` + }, + { + description: strings.EXAMPLES.EX4, + options: `"/a/ibmuser/testcases" -fi` } ] }; diff --git a/packages/cli/src/zosfiles/delete/vsam/Vsam.definition.ts b/packages/cli/src/zosfiles/delete/vsam/Vsam.definition.ts index 08893a34e0..d05ecacd87 100644 --- a/packages/cli/src/zosfiles/delete/vsam/Vsam.definition.ts +++ b/packages/cli/src/zosfiles/delete/vsam/Vsam.definition.ts @@ -61,6 +61,13 @@ export const VsamDefinition: ICommandDefinition = { description: strings.OPTIONS.PURGE, type: "boolean", defaultValue: false + }, + { + name: "ignore-not-found", + aliases: ["i", "inf"], + description: strings.OPTIONS.IGNORE_NF, + type: "boolean", + required: false } ] as ICommandOptionDefinition[]).sort((a, b) => a.name.localeCompare(b.name)), examples: [ @@ -79,6 +86,10 @@ export const VsamDefinition: ICommandDefinition = { { description: strings.EXAMPLES.EX4, options: `"ibmuser.cntl.vsam" -f --erase` - } + }, + { + description: strings.EXAMPLES.EX2, + options: `"ibmuser.cntl.vsam" -fi` + }, ] }; diff --git a/packages/cli/src/zosfiles/delete/vsam/Vsam.handler.ts b/packages/cli/src/zosfiles/delete/vsam/Vsam.handler.ts index 042da15bb3..102ff29dd0 100644 --- a/packages/cli/src/zosfiles/delete/vsam/Vsam.handler.ts +++ b/packages/cli/src/zosfiles/delete/vsam/Vsam.handler.ts @@ -9,7 +9,7 @@ * */ -import { AbstractSession, IHandlerParameters } from "@zowe/imperative"; +import { AbstractSession, IHandlerParameters, ImperativeError } from "@zowe/imperative"; import { Delete, IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk"; import { ZosFilesBaseHandler } from "../../ZosFilesBase.handler"; @@ -18,10 +18,26 @@ import { ZosFilesBaseHandler } from "../../ZosFilesBase.handler"; */ export default class VsamHandler extends ZosFilesBaseHandler { public async processWithSession(commandParameters: IHandlerParameters, session: AbstractSession): Promise { - return Delete.vsam(session, commandParameters.arguments.dataSetName, { - erase: commandParameters.arguments.erase, - purge: commandParameters.arguments.purge, - responseTimeout: commandParameters.arguments.responseTimeout - }); + try { + const response = await Delete.vsam(session, commandParameters.arguments.dataSetName, { + erase: commandParameters.arguments.erase, + purge: commandParameters.arguments.purge, + responseTimeout: commandParameters.arguments.responseTimeout + }); + + return response; + } catch (error: any) { + if (commandParameters.arguments.ignoreNotFound && + (error.errorCode === '404' || error.toString().includes("IDC3012I"))) { + return { success: true, commandResponse: "VSAM dataset not found but this is ignored" }; + } + if (error instanceof ImperativeError){ + throw error; + } + throw new ImperativeError({ + msg: error.message, + causeErrors: error + }); + } } -} +} \ No newline at end of file diff --git a/packages/cli/src/zosfiles/delete/zfs/zfs.definition.ts b/packages/cli/src/zosfiles/delete/zfs/zfs.definition.ts index d9a35a47df..38aed62ad1 100644 --- a/packages/cli/src/zosfiles/delete/zfs/zfs.definition.ts +++ b/packages/cli/src/zosfiles/delete/zfs/zfs.definition.ts @@ -47,12 +47,23 @@ export const ZfsDefinition: ICommandDefinition = { description: strings.OPTIONS.FOR_SURE, type: "boolean", required: true + }, + { + name: "ignore-not-found", + aliases: ["i", "inf"], + description: strings.OPTIONS.IGNORE_NF, + type: "boolean", + required: false } ] as ICommandOptionDefinition[]).sort((a, b) => a.name.localeCompare(b.name)), examples: [ { description: strings.EXAMPLES.EX1, options: `"HLQ.MYNEW.ZFS" -f` + }, + { + description: strings.EXAMPLES.EX2, + options: `"HLQ.MYNEW.ZFS" -fi` } ] }; diff --git a/zowe-cli.ppf b/zowe-cli.ppf index 4012115a7c..a33d3c3c86 100644 --- a/zowe-cli.ppf +++ b/zowe-cli.ppf @@ -1,5 +1,5 @@ -