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

Function NewCmdView

pkg/cmd/repo/autolink/view/view.go:28–60  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*viewOptions) error)

Source from the content-addressed store, hash-verified

26}
27
28func NewCmdView(f *cmdutil.Factory, runF func(*viewOptions) error) *cobra.Command {
29 opts := &viewOptions{
30 Browser: f.Browser,
31 IO: f.IOStreams,
32 }
33
34 cmd := &cobra.Command{
35 Use: "view <id>",
36 Short: "View an autolink reference",
37 Long: "View an autolink reference for a repository.",
38 Args: cobra.ExactArgs(1),
39 RunE: func(cmd *cobra.Command, args []string) error {
40 httpClient, err := f.HttpClient()
41 if err != nil {
42 return err
43 }
44
45 opts.BaseRepo = f.BaseRepo
46 opts.ID = args[0]
47 opts.AutolinkClient = &AutolinkViewer{HTTPClient: httpClient}
48
49 if runF != nil {
50 return runF(opts)
51 }
52
53 return viewRun(opts)
54 },
55 }
56
57 cmdutil.AddJSONFlags(cmd, &opts.Exporter, shared.AutolinkFields)
58
59 return cmd
60}
61
62func viewRun(opts *viewOptions) error {
63 repo, err := opts.BaseRepo()

Callers 1

TestNewCmdViewFunction · 0.70

Calls 2

AddJSONFlagsFunction · 0.92
viewRunFunction · 0.70

Tested by 1

TestNewCmdViewFunction · 0.56