fix(confirm,choose,file,input): timeout handling (#718)

* 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>
This commit is contained in:
Carlos Alexandro Becker 2024-11-18 10:49:15 -03:00 committed by GitHub
commit c868aa1c6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 41 additions and 17 deletions

View file

@ -5,6 +5,7 @@ import (
"fmt"
"path/filepath"
"github.com/charmbracelet/gum/internal/exit"
"github.com/charmbracelet/huh"
"github.com/charmbracelet/lipgloss"
)
@ -51,14 +52,14 @@ func (o Options) Run() error {
Value(&path),
),
).
WithTimeout(o.Timeout).
WithShowHelp(o.ShowHelp).
WithKeyMap(keymap).
WithTheme(theme).
Run()
if err != nil {
return err
return exit.Handle(err, o.Timeout)
}
fmt.Println(path)
return nil
}