diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-03 23:07:25 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-03 23:07:25 +0200 |
| commit | 28920ad225992386069d8513d0cf097dd50daeef (patch) | |
| tree | a389450ac6a939ac99f3eb55de865fb24991eede | |
| parent | 93783dc090cb5f5452e893b55a9f50f500f1e8a3 (diff) | |
Task 352: add tui cobra command
| -rw-r--r-- | internal/cli/root.go | 1 | ||||
| -rw-r--r-- | internal/cli/tui.go | 19 | ||||
| -rw-r--r-- | internal/cli/tui_test.go | 28 |
3 files changed, 48 insertions, 0 deletions
diff --git a/internal/cli/root.go b/internal/cli/root.go index f2512b5..11dabc5 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -51,6 +51,7 @@ func NewRootCmd() *cobra.Command { cmd.PersistentFlags().StringVar(&configPath, "config", "", "Path to config file") cmd.AddCommand(newTimerCmd()) cmd.AddCommand(newWorkCmd()) + cmd.AddCommand(newTUICmd()) return cmd } diff --git a/internal/cli/tui.go b/internal/cli/tui.go new file mode 100644 index 0000000..1a8ea21 --- /dev/null +++ b/internal/cli/tui.go @@ -0,0 +1,19 @@ +package cli + +import ( + tuiapp "codeberg.org/snonux/timr/internal/tui" + tea "github.com/charmbracelet/bubbletea" + "github.com/spf13/cobra" +) + +func newTUICmd() *cobra.Command { + return &cobra.Command{ + Use: "tui", + Short: "Launch full-screen TUI", + RunE: func(cmd *cobra.Command, args []string) error { + model := tuiapp.NewModel() + program := tea.NewProgram(model) + return program.Start() + }, + } +} diff --git a/internal/cli/tui_test.go b/internal/cli/tui_test.go new file mode 100644 index 0000000..9d8f481 --- /dev/null +++ b/internal/cli/tui_test.go @@ -0,0 +1,28 @@ +package cli + +import "testing" + +func TestRootContainsTUISubcommand(t *testing.T) { + cmd := NewRootCmd() + + found, _, err := cmd.Find([]string{"tui"}) + if err != nil { + t.Fatalf("Find(tui) error = %v", err) + } + if found == nil { + t.Fatal("Find(tui) returned nil command") + } + if found.Use != "tui" { + t.Fatalf("found.Use = %q, want %q", found.Use, "tui") + } +} + +func TestNewTUICmdMetadata(t *testing.T) { + cmd := newTUICmd() + if cmd.Use != "tui" { + t.Fatalf("Use = %q, want %q", cmd.Use, "tui") + } + if cmd.Short == "" { + t.Fatal("Short description should not be empty") + } +} |
