(cmd *cobra.Command, args []string)
| 37 | } |
| 38 | |
| 39 | func (c *boxesCommand) run(cmd *cobra.Command, args []string) error { |
| 40 | if err := requireAuth(); err != nil { |
| 41 | return err |
| 42 | } |
| 43 | |
| 44 | ctx := cmd.Context() |
| 45 | result, err := sdk.Boxes().List(ctx) |
| 46 | if err != nil { |
| 47 | return convertSDKError(err) |
| 48 | } |
| 49 | |
| 50 | var boxes []generated.Box |
| 51 | if result != nil { |
| 52 | boxes = *result |
| 53 | } |
| 54 | total := len(boxes) |
| 55 | if c.limit > 0 && !c.all && len(boxes) > c.limit { |
| 56 | boxes = boxes[:c.limit] |
| 57 | } |
| 58 | notice := output.TruncationNotice(len(boxes), total) |
| 59 | |
| 60 | if writer.IsStyled() { |
| 61 | table := newTable(cmd.OutOrStdout()) |
| 62 | table.addRow([]string{"ID", "Kind", "Name"}) |
| 63 | for _, b := range boxes { |
| 64 | table.addRow([]string{fmt.Sprintf("%d", b.Id), b.Kind, b.Name}) |
| 65 | } |
| 66 | table.print() |
| 67 | if notice != "" { |
| 68 | fmt.Fprintln(cmd.OutOrStdout(), notice) |
| 69 | } |
| 70 | return nil |
| 71 | } |
| 72 | |
| 73 | return writeOK(boxes, |
| 74 | output.WithSummary(fmt.Sprintf("%d mailboxes", len(boxes))), |
| 75 | output.WithNotice(notice), |
| 76 | output.WithBreadcrumbs(output.Breadcrumb{ |
| 77 | Action: "view", |
| 78 | Command: "hey box <name>", |
| 79 | Description: "View postings in a box", |
| 80 | }), |
| 81 | ) |
| 82 | } |
nothing calls this directly
no test coverage detected