(commentable Commentable, opts *CommentableOptions)
| 149 | } |
| 150 | |
| 151 | func createComment(commentable Commentable, opts *CommentableOptions) error { |
| 152 | switch opts.InputType { |
| 153 | case InputTypeWeb: |
| 154 | openURL := commentable.Link() + "#issuecomment-new" |
| 155 | if opts.IO.IsStdoutTTY() && !opts.Quiet { |
| 156 | fmt.Fprintf(opts.IO.ErrOut, "Opening %s in your browser.\n", text.DisplayURL(openURL)) |
| 157 | } |
| 158 | return opts.OpenInBrowser(openURL) |
| 159 | case InputTypeEditor: |
| 160 | var body string |
| 161 | var err error |
| 162 | if opts.Interactive { |
| 163 | body, err = opts.InteractiveEditSurvey("") |
| 164 | } else { |
| 165 | body, err = opts.EditSurvey("") |
| 166 | } |
| 167 | if err != nil { |
| 168 | return err |
| 169 | } |
| 170 | opts.Body = body |
| 171 | } |
| 172 | |
| 173 | if opts.Interactive { |
| 174 | cont, err := opts.ConfirmSubmitSurvey() |
| 175 | if err != nil { |
| 176 | return err |
| 177 | } |
| 178 | if !cont { |
| 179 | return errors.New("Discarding...") |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | httpClient, err := opts.HttpClient() |
| 184 | if err != nil { |
| 185 | return err |
| 186 | } |
| 187 | |
| 188 | apiClient := api.NewClientFromHTTP(httpClient) |
| 189 | params := api.CommentCreateInput{Body: opts.Body, SubjectId: commentable.Identifier()} |
| 190 | url, err := api.CommentCreate(apiClient, opts.Host, params) |
| 191 | if err != nil { |
| 192 | return err |
| 193 | } |
| 194 | |
| 195 | if !opts.Quiet { |
| 196 | fmt.Fprintln(opts.IO.Out, url) |
| 197 | } |
| 198 | |
| 199 | return nil |
| 200 | } |
| 201 | |
| 202 | func updateComment(commentable Commentable, opts *CommentableOptions) error { |
| 203 | comments := commentable.CurrentUserComments() |
no test coverage detected