Skip to content

Commit

Permalink
Streamlines command.go per PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dpritchett committed Nov 15, 2024
1 parent cf0a8d1 commit 4c55c7c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions confirm/command.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package confirm

import (
"errors"
"fmt"
"os"

Expand Down Expand Up @@ -32,9 +33,7 @@ func (o Options) Run() error {
Run()

if err != nil {
allowErr := o.errIsValidTimeout(err)

if !allowErr {
if !o.errIsValidTimeout(err) {
return fmt.Errorf("unable to run confirm: %w", err)
}
}
Expand All @@ -48,7 +47,7 @@ func (o Options) Run() error {

// errIsValidTimeout returns false unless 1) the user has specified a nonzero timeout and 2) the error is a huh.ErrTimeout.
func (o Options) errIsValidTimeout(err error) bool {
errWasTimeout := err.Error() == huh.ErrTimeout.Error()
errWasTimeout := errors.Is(err, huh.ErrTimeout)
timeoutsExpected := o.Timeout > 0

return errWasTimeout && timeoutsExpected
Expand Down

0 comments on commit 4c55c7c

Please sign in to comment.