mirror of
https://github.com/charmbracelet/gum
synced 2026-03-15 14:15:44 +01:00
* fix(confirm,choose,file,input): timeout handling - some fields were not actually using the `--timeout` value - some fields had different behavior when a timeout did occur. On this matter, it seems to me the best way forward is to specifically say it timed out, and after how long - added exit status 124 (copied from `timeout` from coreutils) (fixes #684) Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * Update main.go Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com> * Update internal/exit/exit.go Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com> * fix: improve Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: stderr --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com> Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
26 lines
552 B
Go
26 lines
552 B
Go
package exit
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/charmbracelet/huh"
|
|
)
|
|
|
|
// StatusTimeout is the exit code for timed out commands.
|
|
const StatusTimeout = 124
|
|
|
|
// StatusAborted is the exit code for aborted commands.
|
|
const StatusAborted = 130
|
|
|
|
// ErrAborted is the error to return when a gum command is aborted by Ctrl+C.
|
|
var ErrAborted = huh.ErrUserAborted
|
|
|
|
// Handle handles the error.
|
|
func Handle(err error, d time.Duration) error {
|
|
if errors.Is(err, huh.ErrTimeout) {
|
|
return fmt.Errorf("%w after %s", huh.ErrTimeout, d)
|
|
}
|
|
return err
|
|
}
|