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

Function NewCmdView

pkg/cmd/event/subscription/view/view.go:31–62  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*ViewOptions) error)

Source from the content-addressed store, hash-verified

29}
30
31func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Command {
32 opts := &ViewOptions{
33 IO: f.IOStreams,
34 Config: f.Config,
35 EventClient: shared.EventClientFunc(f),
36 Now: time.Now,
37 }
38
39 cmd := &cobra.Command{
40 Use: "view <id>",
41 Short: "View an event subscription (preview)",
42 Example: heredoc.Doc(`
43 # View a subscription
44 $ gh event subscription view sub_123
45
46 # Print when a subscription expires
47 $ gh event subscription view sub_123 --json expiresAt --jq .expiresAt
48 `),
49 Args: cmdutil.ExactArgs(1, "subscription ID required"),
50 RunE: func(cmd *cobra.Command, args []string) error {
51 opts.ID = args[0]
52
53 if runF != nil {
54 return runF(opts)
55 }
56 return viewRun(cmd.Context(), opts)
57 },
58 }
59
60 cmdutil.AddJSONFlags(cmd, &opts.Exporter, client.SubscriptionFields)
61 return cmd
62}
63
64func viewRun(ctx context.Context, opts *ViewOptions) error {
65 cfg, err := opts.Config()

Callers 1

TestNewCmdViewFunction · 0.70

Calls 4

EventClientFuncFunction · 0.92
ExactArgsFunction · 0.92
AddJSONFlagsFunction · 0.92
viewRunFunction · 0.70

Tested by 1

TestNewCmdViewFunction · 0.56