-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> * Update main.go Co-authored-by: Ayman Bagabas <[email protected]> * Update internal/exit/exit.go Co-authored-by: ccoVeille <[email protected]> * fix: improve Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: stderr --------- Signed-off-by: Carlos Alexandro Becker <[email protected]> Co-authored-by: Ayman Bagabas <[email protected]> Co-authored-by: ccoVeille <[email protected]>
- Loading branch information
1 parent
3cec9b7
commit c868aa1
Showing
6 changed files
with
41 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
package exit | ||
|
||
import "fmt" | ||
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 = fmt.Errorf("aborted") | ||
// 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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters