summaryrefslogtreecommitdiff
path: root/internal/commands/tui.go
blob: 774e982523f6edc20ea60427c9a8763b84b70526 (plain)
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
package commands

import (
	"fmt"

	punchctx "git.tjp.lol/punchcard/internal/context"
	"git.tjp.lol/punchcard/internal/tui"

	"github.com/spf13/cobra"
)

func NewTUICmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "tui",
		Short: "Start the terminal user interface",
		Long:  `Start an interactive terminal user interface for time tracking with real-time updates.`,
		Args:  cobra.NoArgs,
		RunE: func(cmd *cobra.Command, args []string) error {
			q := punchctx.GetDB(cmd.Context())
			if q == nil {
				return fmt.Errorf("database not available in context")
			}

			return tui.Run(cmd.Context(), q)
		},
	}

	return cmd
}