MCPcopy Create free account
hub / github.com/cli/cli / readContent

Function readContent

pkg/cmd/issue/artifact/edit/edit.go:261–274  ·  view source on GitHub ↗

readContent returns the new content from --body or --body-file, or nil when neither was given, and the directory a --body-file's references resolve against, which is empty for any other content. Standard input is only read with --body-file -, so a stdin that never closes can't hang the command.

(opts *EditOptions)

Source from the content-addressed store, hash-verified

259// only read with --body-file -, so a stdin that never closes can't hang the
260// command.
261func readContent(opts *EditOptions) (*string, string, error) {
262 if opts.BodyFile == "" {
263 return opts.Body, "", nil
264 }
265 content, dir, err := shared.ReadContent(opts.BodyFile, opts.IO.In)
266 if err != nil {
267 source := opts.BodyFile
268 if source == "-" {
269 source = "standard input"
270 }
271 return nil, "", fmt.Errorf("failed to read new content for artifact %d from %s: %w", opts.ArtifactNumber, source, err)
272 }
273 return &content, dir, nil
274}
275
276// newBody returns the body to save, checked against the artifact's type, or
277// nil to keep the current body. Only a type that supports attachments takes

Callers 1

editRunFunction · 0.85

Calls 2

ReadContentFunction · 0.92
ErrorfMethod · 0.65

Tested by

no test coverage detected