refactor survery cmd
move package files to pkg
This commit is contained in:
32
pkg/task/runner.go
Normal file
32
pkg/task/runner.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
func (t *Task) StartInterface(ctx context.Context, cfg TaskConfig) error {
|
||||
if t.interfaceType == nil {
|
||||
return fmt.Errorf("interfaceType is not set")
|
||||
}
|
||||
|
||||
return t.interfaceType.Run(ctx, cfg)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user