-
Notifications
You must be signed in to change notification settings - Fork 3
copy frontend #920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
copy frontend #920
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /** | ||
| * This program and the accompanying materials are made available under the terms of the | ||
| * Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-v20.html | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Copyright Contributors to the Zowe Project. | ||
| * | ||
| */ | ||
|
|
||
| import type { ICommandDefinition } from "@zowe/imperative"; | ||
| import { SshSession } from "@zowe/zos-uss-for-zowe-sdk"; | ||
| import { Constants } from "../Constants"; | ||
| import { CopyDataSetDefinition } from "./data-set/DataSet.definition"; | ||
|
|
||
| const CopyDefinition: ICommandDefinition = { | ||
| name: "copy", | ||
| aliases: ["cp"], | ||
| summary: "Copy data sets and members", | ||
| description: "Copy a data set or member to another data set or member", | ||
| type: "group", | ||
| children: [CopyDataSetDefinition], | ||
| passOn: [ | ||
| { | ||
| property: "options", | ||
| value: [...SshSession.SSH_CONNECTION_OPTIONS, Constants.OPT_SERVER_PATH], | ||
| merge: true, | ||
| ignoreNodes: [{ type: "group" }], | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| export = CopyDefinition; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /** | ||
| * This program and the accompanying materials are made available under the terms of the | ||
| * Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-v20.html | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Copyright Contributors to the Zowe Project. | ||
| * | ||
| */ | ||
|
|
||
| import type { ICommandDefinition } from "@zowe/imperative"; | ||
|
|
||
| export const CopyDataSetDefinition: ICommandDefinition = { | ||
| handler: `${__dirname}/DataSet.handler`, | ||
| description: | ||
| "Copy a data set or member to another data set or member. " + | ||
| "Supports PDS-to-PDS, member-to-member, and sequential-to-sequential copies. " + | ||
| "Note: RECFM=U data sets are not supported.", | ||
| type: "command", | ||
| name: "data-set", | ||
| aliases: ["ds"], | ||
| summary: "Copy a data set", | ||
| examples: [ | ||
| { | ||
| description: "Copy a sequential data set to a new sequential data set", | ||
| options: '"ibmuser.source.seq" "ibmuser.target.seq"', | ||
| }, | ||
| { | ||
| description: "Copy a PDS to a new PDS (copies all members)", | ||
| options: '"ibmuser.source.pds" "ibmuser.target.pds"', | ||
| }, | ||
| { | ||
| description: "Copy a single member to another PDS", | ||
| options: '"ibmuser.source.pds(member)" "ibmuser.target.pds(member)"', | ||
| }, | ||
| { | ||
| description: "Copy a PDS and replace existing members in the target", | ||
| options: '"ibmuser.source.pds" "ibmuser.target.pds" --replace', | ||
| }, | ||
| { | ||
| description: "Copy a PDS and delete all target members before copying (makes target match source exactly)", | ||
| options: '"ibmuser.source.pds" "ibmuser.target.pds" --delete-target-members', | ||
| }, | ||
| ], | ||
| positionals: [ | ||
| { | ||
| name: "fromDataset", | ||
| description: "The source data set to copy from (can include member name in parentheses)", | ||
| type: "string", | ||
| required: true, | ||
| }, | ||
| { | ||
| name: "toDataset", | ||
| description: "The target data set to copy to (can include member name in parentheses)", | ||
| type: "string", | ||
| required: true, | ||
| }, | ||
| ], | ||
| options: [ | ||
| { | ||
| name: "replace", | ||
| aliases: ["r"], | ||
| description: | ||
| "Replace existing data. For PDS-to-PDS: replaces matching members, preserves target-only members. " + | ||
| "For sequential or member-to-member: overwrites the target.", | ||
| type: "boolean", | ||
| defaultValue: false, | ||
| }, | ||
| { | ||
| name: "delete-target-members", | ||
| aliases: ["d"], | ||
| description: | ||
| "Delete all members from target PDS before copying (PDS-to-PDS copy only). " + | ||
| "Makes the target match the source exactly.", | ||
| type: "boolean", | ||
| defaultValue: false, | ||
| }, | ||
| ], | ||
| profile: { optional: ["ssh"] }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /** | ||
| * This program and the accompanying materials are made available under the terms of the | ||
| * Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-v20.html | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Copyright Contributors to the Zowe Project. | ||
| * | ||
| */ | ||
|
|
||
| import type { IHandlerParameters } from "@zowe/imperative"; | ||
| import type { ds, ZSshClient } from "zowe-native-proto-sdk"; | ||
| import { SshBaseHandler } from "../../SshBaseHandler"; | ||
|
|
||
| export default class CopyDataSetHandler extends SshBaseHandler { | ||
| public async processWithClient(params: IHandlerParameters, client: ZSshClient): Promise<ds.CopyDatasetResponse> { | ||
| const fromDataset = params.arguments.fromDataset; | ||
| const toDataset = params.arguments.toDataset; | ||
| const replace = params.arguments.replace ?? false; | ||
| const deleteTargetMembers = params.arguments.deleteTargetMembers ?? false; | ||
|
|
||
| const response = await client.ds.copyDataset({ fromDataset, toDataset, replace, deleteTargetMembers }); | ||
|
|
||
| let dsMessage: string; | ||
| if (response.success) { | ||
| if (response.targetCreated) { | ||
| dsMessage = `Data set "${toDataset}" created and copied from "${fromDataset}"`; | ||
| } else if (deleteTargetMembers) { | ||
| dsMessage = `Target members deleted and data set "${toDataset}" replaced with contents of "${fromDataset}"`; | ||
| } else if (replace) { | ||
| dsMessage = `Data set "${toDataset}" updated with contents of "${fromDataset}"`; | ||
| } else { | ||
| dsMessage = `Data set "${fromDataset}" copied to "${toDataset}"`; | ||
| } | ||
| } else { | ||
| const r = response as ds.CopyDatasetResponse & { stderr?: string; message?: string }; | ||
|
Check warning on line 37 in packages/cli/src/copy/data-set/DataSet.handler.ts
|
||
| const detail = r.stderr?.trim() || r.message?.trim(); | ||
|
ATorrise marked this conversation as resolved.
|
||
| dsMessage = detail | ||
| ? `Copy failed: "${fromDataset}" to "${toDataset}": ${detail}` | ||
| : `Copy failed: "${fromDataset}" to "${toDataset}"`; | ||
| } | ||
|
|
||
| params.response.data.setMessage(dsMessage); | ||
| params.response.data.setObj(response); | ||
| if (response.success) { | ||
| params.response.console.log(dsMessage); | ||
| } else { | ||
| params.response.console.error(dsMessage); | ||
| params.response.data.setExitCode(1); | ||
| } | ||
| return response; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.