(hotfix) make sure app is initialized only when we need it

This commit is contained in:
Robin Olsen
2026-03-02 11:41:57 +01:00
parent 1baf6c7ff4
commit cb10aeff6b
3 changed files with 95 additions and 11 deletions

View File

@@ -15,6 +15,20 @@ import (
func runStartCmd(cmd *cobra.Command, args []string) error {
app := survey.AppFromContext(cmd.Context())
if app == nil {
if err := ensureAppInitialized(cmd.Context()); err != nil {
return fmt.Errorf("failed to initialize services: %w", err)
}
app = survey.AppFromContext(cmd.Context())
if app == nil {
app = App
}
}
if app == nil {
return fmt.Errorf("application services are not available")
}
interfaces := initInterfaces()
surveyTasks := initTasks(app)
@@ -53,6 +67,14 @@ func taskLoop(ctx context.Context, surveyTasks map[string]task.Tasker, interface
iNames = append(iNames, name)
}
if len(iNames) == 0 {
return fmt.Errorf("no interfaces are available")
}
if len(surveyTasks) == 0 {
return fmt.Errorf("no tasks are available")
}
rand.Shuffle(len(iNames), func(i, j int) {
iNames[i], iNames[j] = iNames[j], iNames[i]
})