@@ -64,23 +64,39 @@ var activityCmd = &cobra.Command{
6464 Run : func (cmd * cobra.Command , args []string ) {
6565 activities , _ := data .GetActivities ()
6666 today , _ := cmd .Flags ().GetBool ("today" )
67- t := table .New ().
68- Border (lipgloss .NormalBorder ()).
69- Headers ("ID" , "Date" , "Time" , "Description" )
7067
68+ rows := make ([][]string , 0 )
69+ runningIndex := 0
7170 for _ , activity := range activities {
7271 if ! today || activity .Date == time .Now ().Format ("2006-01-02" ) {
73- prefix := " "
7472 duration := time .Duration (activity .Seconds * 1000000000 )
7573 if activity .TimerStartedAt != "" {
76- prefix = "*"
7774 started , _ := time .Parse ("2006-01-02T15:04:05Z" , activity .TimerStartedAt )
7875 elapsed := time .Since (started ).Round (time .Second )
7976 duration += elapsed
77+ runningIndex = len (rows ) + 1
8078 }
81- t .Row (fmt .Sprintf ("%d" , activity .Id ), activity .Date , fmt .Sprintf ("%s%s" , prefix , duration .String ()), activity .Description )
79+ id := fmt .Sprintf ("%d" , activity .Id )
80+ date := activity .Date
81+ time := duration .String ()
82+ desc := activity .Description
83+ rows = append (rows , []string {id , date , time , desc })
8284 }
8385 }
86+ t := table .New ().
87+ Border (lipgloss .NormalBorder ()).
88+ Headers ("ID" , "Date" , "Time" , "Description" ).
89+ StyleFunc (func (row int , col int ) lipgloss.Style {
90+ if (runningIndex < 1 ) {
91+ return lipgloss.Style {}
92+ }
93+
94+ if runningIndex == row {
95+ return lipgloss .NewStyle ().Foreground (lipgloss .Color ("9" )).Bold (true )
96+ }
97+ return lipgloss.Style {}
98+ }).
99+ Rows (rows ... )
84100 fmt .Println (t )
85101 },
86102}
0 commit comments