From 67e16265ab5f2cd819c0fa302a99490099dc35a7 Mon Sep 17 00:00:00 2001 From: Robin Olsen Date: Mon, 23 Feb 2026 12:26:23 +0100 Subject: [PATCH] add utility to end tass with timeout --- cmd/survey/tasks/base.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/survey/tasks/base.go b/cmd/survey/tasks/base.go index 3432e5d..ee5a909 100644 --- a/cmd/survey/tasks/base.go +++ b/cmd/survey/tasks/base.go @@ -1,6 +1,9 @@ package tasks import ( + "fmt" + "time" + "github.com/LazyBachelor/LazyPM/internal/service" "github.com/LazyBachelor/LazyPM/pkg/repl" "github.com/LazyBachelor/LazyPM/pkg/task" @@ -90,3 +93,12 @@ func TUIQuestion(interfaceType task.InterfaceType, fields ...huh.Field) *huh.Gro } return huh.NewGroup(fields...) } + +func EndTaskWithTimeout(taskDone *bool, message string, timeout time.Duration) (bool, error) { + if !*taskDone { + *taskDone = true + return false, fmt.Errorf("%s", message) + } + time.Sleep(timeout) + return true, nil +}