add utility to end tass with timeout

This commit is contained in:
Robin Olsen
2026-02-23 12:26:23 +01:00
parent 94917e4ff5
commit 67e16265ab

View File

@@ -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
}