MCPcopy
hub / github.com/cli/cli / viewRun

Function viewRun

pkg/cmd/repo/autolink/view/view.go:62–96  ·  view source on GitHub ↗
(opts *viewOptions)

Source from the content-addressed store, hash-verified

60}
61
62func viewRun(opts *viewOptions) error {
63 repo, err := opts.BaseRepo()
64 if err != nil {
65 return err
66 }
67
68 out := opts.IO.Out
69 cs := opts.IO.ColorScheme()
70
71 autolink, err := opts.AutolinkClient.View(repo, opts.ID)
72
73 if err != nil {
74 return fmt.Errorf("%s %w", cs.Red("error viewing autolink:"), err)
75 }
76
77 if opts.Exporter != nil {
78 return opts.Exporter.Write(opts.IO, autolink)
79 }
80
81 fmt.Fprintf(out, "Autolink in %s\n\n", cs.Bold(ghrepo.FullName(repo)))
82
83 fmt.Fprint(out, cs.Bold("ID: "))
84 fmt.Fprintln(out, cs.Cyanf("%d", autolink.ID))
85
86 fmt.Fprint(out, cs.Bold("Key Prefix: "))
87 fmt.Fprintln(out, autolink.KeyPrefix)
88
89 fmt.Fprint(out, cs.Bold("URL Template: "))
90 fmt.Fprintln(out, autolink.URLTemplate)
91
92 fmt.Fprint(out, cs.Bold("Alphanumeric: "))
93 fmt.Fprintln(out, autolink.IsAlphanumeric)
94
95 return nil
96}

Callers 2

TestViewRunFunction · 0.70
NewCmdViewFunction · 0.70

Calls 9

FullNameFunction · 0.92
ColorSchemeMethod · 0.80
RedMethod · 0.80
BoldMethod · 0.80
CyanfMethod · 0.80
BaseRepoMethod · 0.65
ViewMethod · 0.65
ErrorfMethod · 0.65
WriteMethod · 0.65

Tested by 1

TestViewRunFunction · 0.56