(cmd *cobra.Command, args []string)
| 29 | return calendarsCommand |
| 30 | } |
| 31 | |
| 32 | func (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 | } |
nothing calls this directly
no test coverage detected