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

Function renderPullRequestTTY

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

Source from the content-addressed store, hash-verified

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