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

Method run

internal/cmd/boxes.go:39–82  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

37}
38
39func (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}

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected