resolveBody determines the comment body from flags or interactive input. defaultBody is used as the initial content in the editor (e.g., existing comment body for edits).
(opts *CommentOptions, defaultBody string)
| 281 | // resolveBody determines the comment body from flags or interactive input. |
| 282 | // defaultBody is used as the initial content in the editor (e.g., existing comment body for edits). |
| 283 | func resolveBody(opts *CommentOptions, defaultBody string) (string, error) { |
| 284 | if opts.BodyFile != "" { |
| 285 | b, err := cmdutil.ReadFile(opts.BodyFile, opts.IO.In) |
| 286 | if err != nil { |
| 287 | return "", err |
| 288 | } |
| 289 | return string(b), nil |
| 290 | } |
| 291 | |
| 292 | if opts.Body != "" { |
| 293 | return opts.Body, nil |
| 294 | } |
| 295 | |
| 296 | body, err := opts.Prompter.MarkdownEditor("Body", defaultBody, false) |
| 297 | if err != nil { |
| 298 | return "", err |
| 299 | } |
| 300 | |
| 301 | return body, nil |
| 302 | } |
no test coverage detected