Files
LazyPM/cmd/survey/init.go
Robin Olsen aabce0b0b2 refactor to use app package instead of service
refactor app to be composable
2026-02-28 23:30:31 +01:00

41 lines
878 B
Go

package main
import (
"context"
"github.com/LazyBachelor/LazyPM/cmd/survey/tasks"
"github.com/LazyBachelor/LazyPM/internal/app"
"github.com/LazyBachelor/LazyPM/pkg/task"
_ "github.com/LazyBachelor/LazyPM/cmd/survey/tasks"
)
func initializeServices(ctx context.Context) (*app.App, func(), error) {
return app.New(ctx, tasks.BaseConfig().WithAutoInit(true))
}
func initInterfaces() map[string]task.Interface {
interfaces := make(map[string]task.Interface)
for _, name := range task.ListInterfaces() {
i, err := task.GetInterface(name)
if err != nil {
continue
}
interfaces[name] = i
}
return interfaces
}
func initTasks(app *app.App) map[string]task.Tasker {
taskMap := make(map[string]task.Tasker)
for _, name := range task.ListTasks() {
t, err := task.GetTask(name, app)
if err != nil {
continue
}
taskMap[name] = t
}
return taskMap
}