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)
| 259 | // only read with --body-file -, so a stdin that never closes can't hang the |
| 260 | // command. |
| 261 | func 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 |
no test coverage detected