Skip to content
Myr

command.go

This file

Path

confirm/command.go

71 lines · 1.6 KiB · Go

Last changed by

chore: prepare v2 (#1116)Drew Smirnoffbefore adoption02d6f06

History of this file

Take it

The walk stopped after 200 commits: lines older than 6837ed2 point at it.

feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2

lines 1–3why, one step back
1package confirm
23import (

fix: detect timeout error and apply default option (#888)Miguel Ibarsbefore adoptione292bbf

line 4why, one step back
4 "context"

feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952

line 5why, one step back
5 "fmt"

feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2

lines 6–7why, one step back
6 "os"
7

chore: update to bubbletea v2 (#1112)Drew Smirnoffbefore adoptionf6dd28e

lines 8–9why, one step back
8 "charm.land/bubbles/v2/help"
9 tea "charm.land/bubbletea/v2"

chore: prepare v2 (#1116)Drew Smirnoffbefore adoption02d6f06

lines 10–13why, one step back
10 "charm.land/gum/v2/internal/exit"
11 "charm.land/gum/v2/internal/stdin"12 "charm.land/gum/v2/internal/timeout"13 "charm.land/gum/v2/style"

feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2

lines 14–18why, one step back
14)
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 {

feat: yes|gum confirm (#772)Carlos Alexandro Beckerbefore adoption0b89ff8

lines 19–24why, one step back
19 line, err := stdin.Read(stdin.SingleLine(true))
20 if err == nil {21 switch line {22 case "yes", "y":23 return nil24 default:

fix(confirm): do not print 'not confirmed' on exit 1 (#814)Carlos Alexandro Beckerbefore adoption30bc180

line 25why, one step back
25 return exit.ErrExit(1)

feat: yes|gum confirm (#772)Carlos Alexandro Beckerbefore adoption0b89ff8

lines 26–28why, one step back
26 }
27 }28

feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952

lines 29–31why, one step back
29 ctx, cancel := timeout.Context(o.Timeout)
30 defer cancel()31

feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525

line 32why, one step back
32 top, right, bottom, left := style.ParsePadding(o.Padding)

feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952

line 33why, one step back
33 m := model{

refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e

lines 34–35why, one step back
34 affirmative: o.Affirmative,
35 negative: o.Negative,

feat(confirm): add `--show-output` (#427)vahnrrbefore adoptiond1bfd56

line 36why, one step back
36 showOutput: o.ShowOutput,

refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e

lines 37–45why, one step back
37 confirmation: o.Default,
38 defaultSelection: o.Default,39 keys: defaultKeymap(o.Affirmative, o.Negative),40 help: help.New(),41 showHelp: o.ShowHelp,42 prompt: o.Prompt,43 selectedStyle: o.SelectedStyle.ToLipgloss(),44 unselectedStyle: o.UnselectedStyle.ToLipgloss(),45 promptStyle: o.PromptStyle.ToLipgloss(),

feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525

line 46why, one step back
46 padding: []int{top, right, bottom, left},

feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952

lines 47–52why, one step back
47 }
48 tm, err := tea.NewProgram(49 m,50 tea.WithOutput(os.Stderr),51 tea.WithContext(ctx),52 ).Run()

fix: detect timeout error and apply default option (#888)Miguel Ibarsbefore adoptione292bbf

line 53why, one step back
53 if err != nil && ctx.Err() != context.DeadlineExceeded {

feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952

line 54why, one step back
54 return fmt.Errorf("unable to confirm: %w", err)

feat(confirm): add `--show-output` (#427)vahnrrbefore adoptiond1bfd56

line 55why, one step back
55 }

fix(confirm): ensure `--show-output` show the right answer (#853)Andrey Neringbefore adoption2b72e80

line 56why, one step back
56 m = tm.(model)

feat(confirm): add `--show-output` (#427)vahnrrbefore adoptiond1bfd56

lines 57–63why, one step back
57
58 if o.ShowOutput {59 confirmationText := m.negative60 if m.confirmation {61 confirmationText = m.affirmative62 }63 fmt.Println(m.prompt, confirmationText)

feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2

lines 64–65why, one step back
64 }
65

refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e

lines 66–68why, one step back
66 if m.confirmation {
67 return nil68 }

feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2

line 69why, one step back
69

fix(confirm): do not print 'not confirmed' on exit 1 (#814)Carlos Alexandro Beckerbefore adoption30bc180

line 70why, one step back
70 return exit.ErrExit(1)

feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2

line 71why, one step back
71}