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

Method run

internal/cmd/todo.go:60–117  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

58}
59
60func (c *todoListCommand) run(cmd *cobra.Command, args []string) error {
61 if err := requireAuth(); err != nil {
62 return err
63 }
64
65 ctx := cmd.Context()
66 resp, err := listPersonalRecordings(ctx)
67 if err != nil {
68 return err
69 }
70
71 todos := filterRecordingsByType(resp, "Calendar::Todo")
72
73 total := len(todos)
74 if c.limit > 0 && !c.all && len(todos) > c.limit {
75 todos = todos[:c.limit]
76 }
77 notice := output.TruncationNotice(len(todos), total)
78
79 if writer.IsStyled() {
80 if len(todos) == 0 {
81 fmt.Fprintln(cmd.OutOrStdout(), "No todos.")
82 return nil
83 }
84
85 table := newTable(cmd.OutOrStdout())
86 table.addRow([]string{"ID", "Title", "Date", "Done"})
87 for _, t := range todos {
88 done := ""
89 if !t.CompletedAt.IsZero() {
90 done = "yes"
91 }
92 table.addRow([]string{fmt.Sprintf("%d", t.Id), t.Title, formatDate(t.StartsAt), done})
93 }
94 table.print()
95 if notice != "" {
96 fmt.Fprintln(cmd.OutOrStdout(), notice)
97 }
98 return nil
99 }
100
101 return writeOK(todos,
102 output.WithSummary(fmt.Sprintf("%d todos", len(todos))),
103 output.WithNotice(notice),
104 output.WithBreadcrumbs(
105 output.Breadcrumb{
106 Action: "add",
107 Command: "hey todo add '...'",
108 Description: "Add a new todo",
109 },
110 output.Breadcrumb{
111 Action: "complete",
112 Command: "hey todo complete <id>",
113 Description: "Mark a todo as complete",
114 },
115 ),
116 )
117}

Callers

nothing calls this directly

Calls 13

TruncationNoticeFunction · 0.92
WithSummaryFunction · 0.92
WithNoticeFunction · 0.92
WithBreadcrumbsFunction · 0.92
requireAuthFunction · 0.85
listPersonalRecordingsFunction · 0.85
filterRecordingsByTypeFunction · 0.85
newTableFunction · 0.85
formatDateFunction · 0.85
writeOKFunction · 0.85
IsStyledMethod · 0.80
addRowMethod · 0.80

Tested by

no test coverage detected