MCPcopy Create free account
hub / github.com/basecamp/hey-cli / run

Method run

internal/cmd/calendars.go:31–66  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

29 return calendarsCommand
30}
31
32func (c *calendarsCommand) run(cmd *cobra.Command, args []string) error {
33 if err := requireAuth(); err != nil {
34 return err
35 }
36
37 ctx := cmd.Context()
38 payload, err := sdk.Calendars().List(ctx)
39 if err != nil {
40 return apierr.FromSDK(err)
41 }
42
43 calendars := unwrapCalendars(payload)
44
45 if writer.IsStyled() {
46 table := newTable(cmd.OutOrStdout())
47 table.addRow([]string{"ID", "Name", "Kind", "Owned"})
48 for _, cal := range calendars {
49 owned := "no"
50 if cal.Owned {
51 owned = "yes"
52 }
53 table.addRow([]string{fmt.Sprintf("%d", cal.Id), cal.Name, cal.Kind, owned})
54 }
55 table.print()
56 return nil
57 }
58
59 return writeOK(calendars,
60 output.WithSummary(fmt.Sprintf("%d calendars", len(calendars))),
61 output.WithBreadcrumbs(output.Breadcrumb{
62 Action: "view",
63 Command: "hey recordings <calendar-id>",
64 Description: "List recordings for a calendar",
65 }),
66 )
67}

Callers

nothing calls this directly

Calls 10

WithSummaryFunction · 0.92
WithBreadcrumbsFunction · 0.92
requireAuthFunction · 0.85
convertSDKErrorFunction · 0.85
unwrapCalendarsFunction · 0.85
newTableFunction · 0.85
writeOKFunction · 0.85
IsStyledMethod · 0.80
addRowMethod · 0.80
printMethod · 0.80

Tested by

no test coverage detected