refactor to use app package instead of service

refactor app to be composable
This commit is contained in:
Robin Olsen
2026-02-28 23:30:31 +01:00
parent ba4d3df669
commit aabce0b0b2
56 changed files with 385 additions and 279 deletions

View File

@@ -7,33 +7,33 @@ import (
"math/rand"
"github.com/LazyBachelor/LazyPM/cmd/survey/tasks"
surveyCmd "github.com/LazyBachelor/LazyPM/internal/commands/survey"
survey "github.com/LazyBachelor/LazyPM/internal/commands/survey"
"github.com/LazyBachelor/LazyPM/internal/models"
"github.com/LazyBachelor/LazyPM/pkg/task"
"github.com/spf13/cobra"
)
func runStartCmd(cmd *cobra.Command, args []string) error {
app := surveyCmd.AppFromContext(cmd.Context())
app := survey.AppFromContext(cmd.Context())
interfaces := initInterfaces()
surveyTasks := initTasks(app)
if cmd.Flags().Changed("interface") {
if _, ok := interfaces[surveyCmd.InterfaceType]; !ok {
if _, ok := interfaces[survey.InterfaceType]; !ok {
return fmt.Errorf("invalid interface, valid are %v", task.ListInterfaces())
}
interfaces = map[string]task.Interface{
surveyCmd.InterfaceType: interfaces[surveyCmd.InterfaceType],
survey.InterfaceType: interfaces[survey.InterfaceType],
}
}
if cmd.Flags().Changed("task") {
if surveyTask := surveyTasks[surveyCmd.Task]; surveyTask == nil {
if surveyTask := surveyTasks[survey.Task]; surveyTask == nil {
return fmt.Errorf("invalid task, valid are %v", task.ListTasks())
}
surveyTasks = map[string]task.Tasker{
surveyCmd.Task: surveyTasks[surveyCmd.Task],
survey.Task: surveyTasks[survey.Task],
}
}