โ– humdrum codex / dots v1.0.0
624 B raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package cli

import (
	"fmt"

	"github.com/charmbracelet/lipgloss"
	"github.com/spf13/cobra"
)

func NewTypesCmd() *cobra.Command {
	return &cobra.Command{
		Use:   "types",
		Short: "List active activity types",
		Args:  cobra.NoArgs,
		RunE: func(cmd *cobra.Command, args []string) error {
			client, err := RequireClient()
			if err != nil {
				return err
			}
			d, err := client.GetDay(Today(), TZ())
			if err != nil {
				return err
			}
			for _, t := range d.Types {
				sw := lipgloss.NewStyle().Foreground(lipgloss.Color(t.Color)).Render("โ—")
				fmt.Printf("%s %s\n", sw, t.Name)
			}
			return nil
		},
	}
}