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

Function renderPullRequestTTY

pkg/cmd/pr/create/create.go:1192–1235  ·  view source on GitHub ↗
(io *iostreams.IOStreams, params map[string]any, state *shared.IssueMetadataState)

Source from the content-addressed store, hash-verified

1190}
1191
1192func renderPullRequestTTY(io *iostreams.IOStreams, params map[string]any, state *shared.IssueMetadataState) error {
1193 cs := io.ColorScheme()
1194 out := io.Out
1195
1196 fmt.Fprint(out, "Would have created a Pull Request with:\n")
1197 fmt.Fprintf(out, "%s: %s\n", cs.Bold("Title"), params["title"].(string))
1198 fmt.Fprintf(out, "%s: %t\n", cs.Bold("Draft"), params["draft"])
1199 fmt.Fprintf(out, "%s: %s\n", cs.Bold("Base"), params["baseRefName"])
1200 fmt.Fprintf(out, "%s: %s\n", cs.Bold("Head"), params["headRefName"])
1201 if len(state.Labels) != 0 {
1202 fmt.Fprintf(out, "%s: %s\n", cs.Bold("Labels"), strings.Join(state.Labels, ", "))
1203 }
1204 if len(state.Reviewers) != 0 {
1205 fmt.Fprintf(out, "%s: %s\n", cs.Bold("Reviewers"), strings.Join(state.Reviewers, ", "))
1206 }
1207 if len(state.Assignees) != 0 {
1208 fmt.Fprintf(out, "%s: %s\n", cs.Bold("Assignees"), strings.Join(state.Assignees, ", "))
1209 }
1210 if len(state.Milestones) != 0 {
1211 fmt.Fprintf(out, "%s: %s\n", cs.Bold("Milestones"), strings.Join(state.Milestones, ", "))
1212 }
1213 if len(state.ProjectTitles) != 0 {
1214 fmt.Fprintf(out, "%s: %s\n", cs.Bold("Projects"), strings.Join(state.ProjectTitles, ", "))
1215 }
1216 fmt.Fprintf(out, "%s: %t\n", cs.Bold("MaintainerCanModify"), params["maintainerCanModify"])
1217
1218 fmt.Fprintf(out, "%s\n", cs.Bold("Body:"))
1219 // Body
1220 var md string
1221 var err error
1222 if len(params["body"].(string)) == 0 {
1223 md = fmt.Sprintf("%s\n", cs.Muted("No description provided"))
1224 } else {
1225 md, err = markdown.Render(params["body"].(string),
1226 markdown.WithTheme(io.TerminalTheme()),
1227 markdown.WithWrap(io.TerminalWidth()))
1228 if err != nil {
1229 return err
1230 }
1231 }
1232 fmt.Fprintf(out, "%s", md)
1233
1234 return nil
1235}
1236
1237func previewPR(opts CreateOptions, openURL string) error {
1238 if opts.IO.IsStdinTTY() && opts.IO.IsStdoutTTY() {

Callers 1

submitPRFunction · 0.85

Calls 9

RenderFunction · 0.92
WithThemeFunction · 0.92
WithWrapFunction · 0.92
ColorSchemeMethod · 0.80
BoldMethod · 0.80
JoinMethod · 0.80
MutedMethod · 0.80
TerminalThemeMethod · 0.80
TerminalWidthMethod · 0.80

Tested by

no test coverage detected