Skip to content
Myr

feat: yes|gum confirm (#772)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* feat: yes|gum confirm Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: rebase on main ---------

authored by Carlos Alexandro Becker · committed by GitHub · parent 4cedf9f · Browse files · 1 file+14 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

Diff stats

1 file+14 added−1 removed

  • other:+14 added−1 removed

1 file+14 added−1 removed

modified:confirm/command.go+14 added-1 removed
5 unmodified lines
6 "os"78 "github.com/charmbracelet/bubbles/help"9 tea "github.com/charmbracelet/bubbletea"10 "github.com/charmbracelet/gum/internal/stdin"11 "github.com/charmbracelet/gum/internal/timeout"12)1314var errNotConfirmed = errors.New("not confirmed")1516// Run provides a shell script interface for prompting a user to confirm an17// action with an affirmative or negative answer.18func (o Options) Run() error {19 line, err := stdin.Read(stdin.SingleLine(true))20 if err == nil {21 switch line {22 case "yes", "y":23 return nil24 default:25 return errNotConfirmed26 }27 }2829 ctx, cancel := timeout.Context(o.Timeout)30 defer cancel()3132 m := model{
31 unmodified lines
64 if m.confirmation {65 return nil66 }6755 return errors.New("not confirmed")68 return errNotConfirmed69}