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