From 2583ca13c39c8d97811501f56977e39e01790f7e Mon Sep 17 00:00:00 2001 From: Robin Olsen Date: Wed, 18 Feb 2026 14:32:08 +0100 Subject: [PATCH] sentralize userquiterror --- cmd/survey/intro.go | 6 ++---- pkg/task/runner.go | 2 -- pkg/task/types.go | 3 +++ pkg/task/ui/task.go | 3 --- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/cmd/survey/intro.go b/cmd/survey/intro.go index 0c09acb..83824d7 100644 --- a/cmd/survey/intro.go +++ b/cmd/survey/intro.go @@ -1,17 +1,15 @@ package main import ( - "errors" "strings" "github.com/LazyBachelor/LazyPM/internal/style" + "github.com/LazyBachelor/LazyPM/pkg/task" "github.com/charmbracelet/bubbles/key" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" ) -var ErrUserQuit = errors.New("user quit") - const stages = 2 const ( @@ -77,7 +75,7 @@ func (m introModel) Run() error { return err } if m, ok := model.(introModel); ok && m.userQuit { - return ErrUserQuit + return task.ErrUserQuit } return nil } diff --git a/pkg/task/runner.go b/pkg/task/runner.go index 6743e0a..37246f9 100644 --- a/pkg/task/runner.go +++ b/pkg/task/runner.go @@ -9,8 +9,6 @@ import ( tea "github.com/charmbracelet/bubbletea" ) -var ErrUserQuit = fmt.Errorf("user quit") - // RunTask orchestrates the complete task execution flow: // 1. Setup the task // 2. Show task intro screen diff --git a/pkg/task/types.go b/pkg/task/types.go index 1ebab9a..9287c6a 100644 --- a/pkg/task/types.go +++ b/pkg/task/types.go @@ -2,6 +2,7 @@ package task import ( "context" + "fmt" "github.com/LazyBachelor/LazyPM/internal/service" taskui "github.com/LazyBachelor/LazyPM/pkg/task/ui" @@ -9,6 +10,8 @@ import ( type TaskConfig = service.Config +var ErrUserQuit = fmt.Errorf("user quit") + type Interface interface { Run(context.Context, TaskConfig) error } diff --git a/pkg/task/ui/task.go b/pkg/task/ui/task.go index d05ea6e..a041421 100644 --- a/pkg/task/ui/task.go +++ b/pkg/task/ui/task.go @@ -1,7 +1,6 @@ package taskui import ( - "errors" "fmt" "strings" @@ -11,8 +10,6 @@ import ( tea "github.com/charmbracelet/bubbletea" ) -var ErrUserQuit = errors.New("user quit") - type TaskDetails struct { Title string Description string