refactor names and minimize dependencies

This commit is contained in:
Robin Olsen
2026-02-28 22:17:55 +01:00
parent bfeeed5626
commit ba4d3df669
25 changed files with 169 additions and 197 deletions

View File

@@ -1,4 +1,4 @@
package taskui
package task
import (
"charm.land/lipgloss/v2"

View File

@@ -2,8 +2,6 @@ package task
import (
"fmt"
"github.com/LazyBachelor/LazyPM/internal/service"
)
var interfaceRegistry = make(map[string]Interface)
@@ -31,16 +29,16 @@ func ListInterfaces() []string {
return names
}
var taskRegistry = make(map[string]func(*service.App) Tasker)
var taskRegistry = make(map[string]func(*App) Tasker)
func RegisterTask(name string, constructor func(*service.App) Tasker) {
func RegisterTask(name string, constructor func(*App) Tasker) {
if _, exists := taskRegistry[name]; exists {
panic(fmt.Sprintf("task %q already registered", name))
}
taskRegistry[name] = constructor
}
func GetTask(name string, app *service.App) (Tasker, error) {
func GetTask(name string, app *App) (Tasker, error) {
constructor, ok := taskRegistry[name]
if !ok {
return nil, fmt.Errorf("task %q not found", name)

View File

@@ -6,10 +6,10 @@ import (
"time"
"github.com/LazyBachelor/LazyPM/internal/models"
taskui "github.com/LazyBachelor/LazyPM/pkg/task/ui"
tea "github.com/charmbracelet/bubbletea"
)
type App = models.App
type Config = models.Config
type Tasker = models.Tasker
@@ -43,7 +43,7 @@ func RunTask(ctx context.Context, t Tasker, i Interface, iType InterfaceType) er
}
// Show task intro
detailsScreen := taskui.NewTaskModel(t.Details())
detailsScreen := NewTaskModel(t.Details())
model, err := tea.NewProgram(detailsScreen, tea.WithAltScreen()).Run()
if err != nil {
return err
@@ -79,7 +79,7 @@ func RunTask(ctx context.Context, t Tasker, i Interface, iType InterfaceType) er
// Show questionnaire
questions := t.Questions(iType)
questionare := taskui.NewQuestionnaireModel(questions)
questionare := NewQuestionnaireModel(questions)
model, err = tea.NewProgram(questionare, tea.WithAltScreen()).Run()
if err != nil {
return err

View File

@@ -1,4 +1,4 @@
package taskui
package task
import (
"fmt"