add exit mechanicm to each stage

remove types and moved struct to appropriate files
This commit is contained in:
Robin Olsen
2026-02-16 13:08:45 +01:00
parent 1fe92d1972
commit b3b45e67be
7 changed files with 111 additions and 65 deletions

View File

@@ -11,8 +11,14 @@ func (t *Task) IntroduceTask() error {
if t.aboutScreen == nil {
return fmt.Errorf("aboutScreen is not set")
}
_, err := tea.NewProgram(t.aboutScreen, tea.WithAltScreen()).Run()
return err
model, err := tea.NewProgram(t.aboutScreen, tea.WithAltScreen()).Run()
if err != nil {
return err
}
if m, ok := model.(interface{ GetUserQuit() bool }); ok && m.GetUserQuit() {
return ErrUserQuit
}
return nil
}
func (t *Task) StartInterface(ctx context.Context, cfg TaskConfig) error {
@@ -27,6 +33,12 @@ func (t *Task) StartQuestionnaire() error {
if t.questionnaire == nil {
return fmt.Errorf("questionnaire is not set")
}
_, err := tea.NewProgram(t.questionnaire, tea.WithAltScreen()).Run()
return err
model, err := tea.NewProgram(t.questionnaire, tea.WithAltScreen()).Run()
if err != nil {
return err
}
if m, ok := model.(interface{ GetUserQuit() bool }); ok && m.GetUserQuit() {
return ErrUserQuit
}
return nil
}