(app *App)
| 708 | } |
| 709 | |
| 710 | func newCpCmd(app *App) *cobra.Command { |
| 711 | var opts cpOptions |
| 712 | |
| 713 | cpCmd := &cobra.Command{ |
| 714 | Use: "cp [-e] [-r] [-- [<scp flags>...]] <sources>... <dest>", |
| 715 | Short: "Copy files between local and remote file systems", |
| 716 | Long: heredoc.Docf(` |
| 717 | The %[1]scp%[1]s command copies files between the local and remote file systems. |
| 718 | |
| 719 | As with the UNIX %[1]scp%[1]s command, the first argument specifies the source and the last |
| 720 | specifies the destination; additional sources may be specified after the first, |
| 721 | if the destination is a directory. |
| 722 | |
| 723 | The %[1]s--recursive%[1]s flag is required if any source is a directory. |
| 724 | |
| 725 | A %[1]sremote:%[1]s prefix on any file name argument indicates that it refers to |
| 726 | the file system of the remote (Codespace) machine. It is resolved relative |
| 727 | to the home directory of the remote user. |
| 728 | |
| 729 | By default, remote file names are interpreted literally. With the %[1]s--expand%[1]s flag, |
| 730 | each such argument is treated in the manner of %[1]sscp%[1]s, as a Bash expression to |
| 731 | be evaluated on the remote machine, subject to expansion of tildes, braces, globs, |
| 732 | environment variables, and backticks. For security, do not use this flag with arguments |
| 733 | provided by untrusted users; see <https://lwn.net/Articles/835962/> for discussion. |
| 734 | |
| 735 | By default, the %[1]scp%[1]s command will create a public/private ssh key pair to authenticate with |
| 736 | the codespace inside the %[1]s~/.ssh directory%[1]s. |
| 737 | `, "`"), |
| 738 | Example: heredoc.Doc(` |
| 739 | $ gh codespace cp -e README.md 'remote:/workspaces/$RepositoryName/' |
| 740 | $ gh codespace cp -e 'remote:~/*.go' ./gofiles/ |
| 741 | $ gh codespace cp -e 'remote:/workspaces/myproj/go.{mod,sum}' ./gofiles/ |
| 742 | $ gh codespace cp -e -- -F ~/.ssh/codespaces_config 'remote:~/*.go' ./gofiles/ |
| 743 | `), |
| 744 | RunE: func(cmd *cobra.Command, args []string) error { |
| 745 | return app.Copy(cmd.Context(), args, opts) |
| 746 | }, |
| 747 | DisableFlagsInUseLine: true, |
| 748 | } |
| 749 | |
| 750 | // We don't expose all sshOptions. |
| 751 | cpCmd.Flags().BoolVarP(&opts.recursive, "recursive", "r", false, "Recursively copy directories") |
| 752 | cpCmd.Flags().BoolVarP(&opts.expand, "expand", "e", false, "Expand remote file names on remote shell") |
| 753 | opts.selector = AddCodespaceSelector(cpCmd, app.apiClient) |
| 754 | cpCmd.Flags().StringVarP(&opts.profile, "profile", "p", "", "Name of the SSH profile to use") |
| 755 | return cpCmd |
| 756 | } |
| 757 | |
| 758 | // Copy copies files between the local and remote file systems. |
| 759 | // The mechanics are similar to 'ssh' but using 'scp'. |
no test coverage detected