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

Method run

internal/cmd/timetrack.go:209–255  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

207func (c *timetrackListCommand) run(cmd *cobra.Command, args []string) error {
208 if err := requireAuth(); err != nil {
209 return err
210 }
211
212 ctx := cmd.Context()
213 resp, err := listPersonalRecordings(ctx)
214 if err != nil {
215 return err
216 }
217
218 tracks := filterRecordingsByType(resp, "Calendar::TimeTrack")
219
220 total := len(tracks)
221 if c.limit > 0 && !c.all && len(tracks) > c.limit {
222 tracks = tracks[:c.limit]
223 }
224 notice := output.TruncationNotice(len(tracks), total)
225
226 if writer.IsStyled() {
227 if len(tracks) == 0 {
228 fmt.Fprintln(cmd.OutOrStdout(), "No time tracks.")
229 return nil
230 }
231
232 table := newTable(cmd.OutOrStdout())
233 table.addRow([]string{"ID", "Title", "Start", "End"})
234 for _, t := range tracks {
235 table.addRow([]string{fmt.Sprintf("%d", t.Id), t.Title, formatTimestamp(t.StartsAt), formatTimestamp(t.EndsAt)})
236 }
237 table.print()
238 if notice != "" {
239 fmt.Fprintln(cmd.OutOrStdout(), notice)
240 }
241 return nil
242 }
243
244 return writeOK(tracks,
245 output.WithSummary(fmt.Sprintf("%d time tracks", len(tracks))),
246 output.WithNotice(notice),
247 output.WithBreadcrumbs(output.Breadcrumb{
248 Action: "start",
249 Command: "hey timetrack start",
250 Description: "Start time tracking",
251 }),
252 )
253}

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
writeOKFunction · 0.85
IsStyledMethod · 0.80
addRowMethod · 0.80
printMethod · 0.80

Tested by

no test coverage detected