refactor to use Tasker interface instead of Task

add tasker register for registering tasks for extiensibility
This commit is contained in:
Robin Olsen
2026-02-18 13:07:23 +01:00
parent 89f8596884
commit 23747fb799
9 changed files with 276 additions and 300 deletions

View File

@@ -2,15 +2,11 @@ package task
import (
"context"
"errors"
"time"
"github.com/LazyBachelor/LazyPM/internal/service"
taskui "github.com/LazyBachelor/LazyPM/pkg/task/ui"
)
var ErrUserQuit = errors.New("user quit")
type TaskConfig = service.Config
type Interface interface {
@@ -25,20 +21,17 @@ const (
InterfaceWeb InterfaceType = "web"
)
type ConfigFunc func() TaskConfig
type ValidateFunc func(context.Context) (ok bool, err error)
type DbStateFunc func(context.Context) error
type QuestionsFunc func(InterfaceType) taskui.Questions
type ValidationFeedback struct {
Success bool
Message string
Timestamp time.Time
type Tasker interface {
Config() TaskConfig
Details() taskui.TaskDetails
Questions(InterfaceType) taskui.Questions
Setup(context.Context) error
Validate(context.Context) (bool, error)
}
type ValidationObserver interface {
OnValidationUpdate(feedback ValidationFeedback)
OnTaskComplete()
type ValidationFeedback struct {
Success bool
Message string
}
type ValidatedInterface interface {