MCPcopy
hub / github.com/cli/cli / NewCmdView

Function NewCmdView

pkg/cmd/release/view/view.go:37–73  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*ViewOptions) error)

Source from the content-addressed store, hash-verified

35}
36
37func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Command {
38 opts := &ViewOptions{
39 IO: f.IOStreams,
40 HttpClient: f.HttpClient,
41 Browser: f.Browser,
42 }
43
44 cmd := &cobra.Command{
45 Use: "view [<tag>]",
46 Short: "View information about a release",
47 Long: heredoc.Doc(`
48 View information about a GitHub Release.
49
50 Without an explicit tag name argument, the latest release in the project
51 is shown.
52 `),
53 Args: cobra.MaximumNArgs(1),
54 RunE: func(cmd *cobra.Command, args []string) error {
55 // support `-R, --repo` override
56 opts.BaseRepo = f.BaseRepo
57
58 if len(args) > 0 {
59 opts.TagName = args[0]
60 }
61
62 if runF != nil {
63 return runF(opts)
64 }
65 return viewRun(opts)
66 },
67 }
68
69 cmd.Flags().BoolVarP(&opts.WebMode, "web", "w", false, "Open the release in the browser")
70 cmdutil.AddJSONFlags(cmd, &opts.Exporter, shared.ReleaseFields)
71
72 return cmd
73}
74
75func viewRun(opts *ViewOptions) error {
76 httpClient, err := opts.HttpClient()

Callers 1

Test_NewCmdViewFunction · 0.70

Calls 2

AddJSONFlagsFunction · 0.92
viewRunFunction · 0.70

Tested by 1

Test_NewCmdViewFunction · 0.56