add utility to end tass with timeout
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
package tasks
|
package tasks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/LazyBachelor/LazyPM/internal/service"
|
"github.com/LazyBachelor/LazyPM/internal/service"
|
||||||
"github.com/LazyBachelor/LazyPM/pkg/repl"
|
"github.com/LazyBachelor/LazyPM/pkg/repl"
|
||||||
"github.com/LazyBachelor/LazyPM/pkg/task"
|
"github.com/LazyBachelor/LazyPM/pkg/task"
|
||||||
@@ -90,3 +93,12 @@ func TUIQuestion(interfaceType task.InterfaceType, fields ...huh.Field) *huh.Gro
|
|||||||
}
|
}
|
||||||
return huh.NewGroup(fields...)
|
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user