From 4842d30aabf97e8d6dac180d802949afde826635 Mon Sep 17 00:00:00 2001 From: Robin Olsen Date: Wed, 4 Mar 2026 22:44:01 +0100 Subject: [PATCH] change repl and status command to use callback --- internal/commands/survey/status.go | 18 +++++++++++++++++- internal/models/task.go | 1 + pkg/repl/repl.go | 11 ++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/internal/commands/survey/status.go b/internal/commands/survey/status.go index 0e5a954..8df5ac0 100644 --- a/internal/commands/survey/status.go +++ b/internal/commands/survey/status.go @@ -1,6 +1,8 @@ package survey import ( + "time" + "github.com/LazyBachelor/LazyPM/internal/commands/issues" "github.com/spf13/cobra" ) @@ -15,11 +17,25 @@ var StatusCmd = &cobra.Command{ func runStatusCmd(cmd *cobra.Command, args []string) error { app := issues.AppFromContext(cmd.Context()) - if app == nil || app.CurrentFeedback == nil { + if app == nil { cmd.Println("No validation status available.") return nil } + if app.SubmitChan != nil { + select { + case app.SubmitChan <- struct{}{}: + default: + } + } + + time.Sleep(100 * time.Millisecond) + + if app.CurrentFeedback == nil { + cmd.Println("No validation status available yet.") + return nil + } + if app.CurrentFeedback.Message == "" { cmd.Println("No validation status available yet.") return nil diff --git a/internal/models/task.go b/internal/models/task.go index 9f0538b..88d385a 100644 --- a/internal/models/task.go +++ b/internal/models/task.go @@ -28,6 +28,7 @@ type Check struct { type ValidatedInterface interface { Interface SetChannels(feedbackChan chan ValidationFeedback, quitChan chan bool) + SetSubmitChan(submitChan chan<- struct{}) } type TaskDetails struct { diff --git a/pkg/repl/repl.go b/pkg/repl/repl.go index 607100d..f91d475 100644 --- a/pkg/repl/repl.go +++ b/pkg/repl/repl.go @@ -31,6 +31,7 @@ You can also run shell commands directly. Type 'exit' or 'quit' to leave.` type REPL struct { feedbackChan chan ValidationFeedback quitChan chan bool + submitChan chan<- struct{} app *App currentFeedback ValidationFeedback @@ -65,7 +66,11 @@ func (r *REPL) Run(ctx context.Context, config app.Config) error { // Store app reference for updating feedback r.app = app - fmt.Println(style.TitleStyle.Render(ReplTitle)) // Print REPL title. + if r.submitChan != nil { + r.app.SubmitChan = r.submitChan + } + + fmt.Println(style.TitleStyle.Render(ReplTitle)) // Start goroutine to watch for validation feedback and quit signals if r.feedbackChan != nil && r.quitChan != nil { @@ -151,6 +156,10 @@ func (r *REPL) SetChannels(feedbackChan chan task.ValidationFeedback, quitChan c r.quitChan = quitChan } +func (r *REPL) SetSubmitChan(submitChan chan<- struct{}) { + r.submitChan = submitChan +} + func (r *REPL) logAction(action string) { if r.app != nil { r.app.LogAction(models.EncodeActionEvent(models.ActionEvent{