Skip to content

Commit 2c180a6

Browse files
committed
Clean up codespace cp docs
- Examples block now moved to its own section - Refer to flags by their full names - Use backticks for delimiting command-line expressions - Use double quotes for literal values
1 parent 9b7d535 commit 2c180a6

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

pkg/cmd/codespace/ssh.go

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"path/filepath"
1313
"strings"
1414

15+
"github.com/MakeNowJust/heredoc"
1516
"github.com/cli/cli/v2/internal/codespaces"
1617
"github.com/cli/cli/v2/pkg/cmdutil"
1718
"github.com/cli/cli/v2/pkg/liveshare"
@@ -156,36 +157,36 @@ func newCpCmd(app *App) *cobra.Command {
156157
var opts cpOptions
157158

158159
cpCmd := &cobra.Command{
159-
Use: "cp [-e] [-r] srcs... dest",
160+
Use: "cp [-e] [-r] <sources>... <dest>",
160161
Short: "Copy files between local and remote file systems",
161-
Long: `
162-
The cp command copies files between the local and remote file systems.
163-
164-
As with the UNIX cp command, the first argument specifies the source and the last
165-
specifies the destination; additional sources may be specified after the first,
166-
if the destination is a directory.
167-
168-
The -r (recursive) flag is required if any source is a directory.
169-
170-
A 'remote:' prefix on any file name argument indicates that it refers to
171-
the file system of the remote (Codespace) machine. It is resolved relative
172-
to the home directory of the remote user.
173-
174-
By default, remote file names are interpreted literally. With the -e flag,
175-
each such argument is treated in the manner of scp, as a Bash expression to
176-
be evaluated on the remote machine, subject to expansion of tildes, braces,
177-
globs, environment variables, and backticks, as in these examples:
178-
179-
$ gh codespace cp -e README.md 'remote:/workspace/$RepositoryName/'
180-
$ gh codespace cp -e 'remote:~/*.go' ./gofiles/
181-
$ gh codespace cp -e 'remote:/workspace/myproj/go.{mod,sum}' ./gofiles/
182-
183-
For security, do not use the -e flag with arguments provided by untrusted
184-
users; see <https://lwn.net/Articles/835962/> for discussion.
185-
`,
162+
Long: heredoc.Docf(`
163+
The cp command copies files between the local and remote file systems.
164+
165+
As with the UNIX %[1]scp%[1]s command, the first argument specifies the source and the last
166+
specifies the destination; additional sources may be specified after the first,
167+
if the destination is a directory.
168+
169+
The %[1]s--recursive%[1]s flag is required if any source is a directory.
170+
171+
A "remote:" prefix on any file name argument indicates that it refers to
172+
the file system of the remote (Codespace) machine. It is resolved relative
173+
to the home directory of the remote user.
174+
175+
By default, remote file names are interpreted literally. With the %[1]s--expand%[1]s flag,
176+
each such argument is treated in the manner of %[1]sscp%[1]s, as a Bash expression to
177+
be evaluated on the remote machine, subject to expansion of tildes, braces, globs,
178+
environment variables, and backticks. For security, do not use this flag with arguments
179+
provided by untrusted users; see <https://lwn.net/Articles/835962/> for discussion.
180+
`, "`"),
181+
Example: heredoc.Doc(`
182+
$ gh codespace cp -e README.md 'remote:/workspace/$RepositoryName/'
183+
$ gh codespace cp -e 'remote:~/*.go' ./gofiles/
184+
$ gh codespace cp -e 'remote:/workspace/myproj/go.{mod,sum}' ./gofiles/
185+
`),
186186
RunE: func(cmd *cobra.Command, args []string) error {
187187
return app.Copy(cmd.Context(), args, opts)
188188
},
189+
DisableFlagsInUseLine: true,
189190
}
190191

191192
// We don't expose all sshOptions.

0 commit comments

Comments
 (0)