From 08ded5384cff5f317b6fc20fa8538287c4488dea Mon Sep 17 00:00:00 2001 From: Robin Olsen Date: Thu, 12 Feb 2026 19:57:52 +0100 Subject: [PATCH] change signature of interfaces to fit Interface interface --- pkg/cli/cli.go | 10 ++++++++-- pkg/cli/repl/repl.go | 8 +++++++- pkg/tui/tui.go | 18 +++++++++++++----- pkg/web/web.go | 8 +++++++- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/pkg/cli/cli.go b/pkg/cli/cli.go index c3f515c..27dd22a 100644 --- a/pkg/cli/cli.go +++ b/pkg/cli/cli.go @@ -11,8 +11,14 @@ import ( // CLIConfig is an alias for service.Config, used to configure the CLI. type CLIConfig = service.Config +type CLI struct{} + +func NewCli() *CLI { + return &CLI{} +} + // Run initializes the services and executes the CLI commands. -func Run(ctx context.Context, config CLIConfig) error { +func (c *CLI) Run(ctx context.Context, config CLIConfig) error { svc, cleanup, err := service.NewServices(ctx, config) if err != nil { return err @@ -30,7 +36,7 @@ func Run(ctx context.Context, config CLIConfig) error { } // RunWithArgs initializes the services and executes the CLI commands with the provided arguments. -func RunWithArgs(ctx context.Context, config CLIConfig, args []string) error { +func (c *CLI) RunWithArgs(ctx context.Context, config CLIConfig, args []string) error { svc, cleanup, err := service.NewServices(ctx, config) if err != nil { return err diff --git a/pkg/cli/repl/repl.go b/pkg/cli/repl/repl.go index cba9569..1e9ffbd 100644 --- a/pkg/cli/repl/repl.go +++ b/pkg/cli/repl/repl.go @@ -22,8 +22,14 @@ You can also run shell commands directly. Type 'exit' or 'quit' to leave.` ReplTitle = "Welcome to Project Management CLI! " + ReplHelp ) +type REPL struct{} + +func NewRepl() *REPL { + return &REPL{} +} + // RunREPL starts the interactive Read-Eval-Print Loop for the PM CLI. -func RunREPL(ctx context.Context, config cli.CLIConfig) error { +func (r *REPL) Run(ctx context.Context, config cli.CLIConfig) error { // Set terminal to raw mode to capture input properly in the REPL. // This allows us to handle input character by character and provide a better user experience. // We also ensure that the terminal state is restored when the REPL exits, even if an error occurs. diff --git a/pkg/tui/tui.go b/pkg/tui/tui.go index b0feda5..7a26ed7 100644 --- a/pkg/tui/tui.go +++ b/pkg/tui/tui.go @@ -10,16 +10,24 @@ import ( type TUIConfig = service.Config -func Run(ctx context.Context, config TUIConfig) (tea.Model, error) { +type Tui struct{} + +func NewTui() *Tui { + return &Tui{} +} + +func (t *Tui) Run(ctx context.Context, config TUIConfig) error { svc, cleanup, err := service.NewServices(ctx, config) if err != nil { - return nil, err + return nil } defer cleanup() - app := tea.NewProgram(views.NewDashboardView(svc), - tea.WithAltScreen(), tea.WithMouseAllMotion()) + if _, err := tea.NewProgram(views.NewDashboardView(svc), + tea.WithAltScreen(), tea.WithMouseAllMotion()).Run(); err != nil { + return err + } - return app.Run() + return nil } diff --git a/pkg/web/web.go b/pkg/web/web.go index 0670da8..f38215c 100644 --- a/pkg/web/web.go +++ b/pkg/web/web.go @@ -11,10 +11,16 @@ import ( type WebConfig = service.Config +type Web struct{} + +func NewWeb() *Web { + return &Web{} +} + //go:embed assets/* var assets embed.FS -func Run(ctx context.Context, config WebConfig) error { +func (w Web) Run(ctx context.Context, config WebConfig) error { svc, cleanup, err := service.NewServices(ctx, config) if err != nil { return err