command.go
This file
Path
input/command.go
81 lines · 1.9 KiB · Go
Last changed by
chore: prepare v2 (#1116)Drew Smirnoffbefore adoption02d6f06
History of this fileTake 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 back1package input23import (feat(choose,confirm,file,filter,input,table,write): esc exit 1, ctrl+c exit 130, help arrow order (#771)Carlos Alexandro Beckerbefore adoption774667a
line 4why, one step back4 "errors"feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 5–7why, one step back5 "fmt"6 "os"7chore: update to bubbletea v2 (#1112)Drew Smirnoffbefore adoptionf6dd28e
lines 8–10why, one step back8 "charm.land/bubbles/v2/help"9 "charm.land/bubbles/v2/textinput"10 tea "charm.land/bubbletea/v2"chore: prepare v2 (#1116)Drew Smirnoffbefore adoption02d6f06
lines 11–14why, one step back11 "charm.land/gum/v2/cursor"12 "charm.land/gum/v2/internal/stdin"13 "charm.land/gum/v2/internal/timeout"14 "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 15–19why, one step back15)1617// Run provides a shell script interface for the text input bubble.18// https://github.com/charmbracelet/bubbles/textinput19func (o Options) Run() error {refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 20why, one step back20 if o.Value == "" {feat: --no-strip-ansi (#784)Carlos Alexandro Beckerbefore adoption4cedf9f
line 21why, one step back21 if in, _ := stdin.Read(stdin.StripANSI(o.StripANSI)); in != "" {refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 22–26why, one step back22 o.Value = in23 }24 }2526 i := textinput.New()feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 27why, one step back27 if o.Value != "" {refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 28why, one step back28 i.SetValue(o.Value)feat: --no-strip-ansi (#784)Carlos Alexandro Beckerbefore adoption4cedf9f
line 29why, one step back29 } else if in, _ := stdin.Read(stdin.StripANSI(o.StripANSI)); in != "" {refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 30why, one step back30 i.SetValue(in)feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 31why, one step back31 }refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 32–34why, one step back32 i.Focus()33 i.Prompt = o.Prompt34 i.Placeholder = o.Placeholderchore: update to bubbletea v2 (#1112)Drew Smirnoffbefore adoptionf6dd28e
lines 35–42why, one step back35 i.SetWidth(o.Width)36 styles := i.Styles()37 styles.Focused.Prompt = o.PromptStyle.ToLipgloss()38 styles.Blurred.Prompt = o.PromptStyle.ToLipgloss()39 styles.Focused.Placeholder = o.PlaceholderStyle.ToLipgloss()40 styles.Blurred.Placeholder = o.PlaceholderStyle.ToLipgloss()41 i.SetStyles(styles)42 cursor.TextInput(&i, o.CursorMode, o.CursorStyle)refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 43why, one step back43 i.CharLimit = o.CharLimitfeat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 44–45why, one step back4445 if o.Password {refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 46–47why, one step back46 i.EchoMode = textinput.EchoPassword47 i.EchoCharacter = '•'feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 48–49why, one step back48 }49feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
line 50why, one step back50 top, right, bottom, left := style.ParsePadding(o.Padding)feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952
line 51why, one step back51 m := model{refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 52–54why, one step back52 textinput: i,53 header: o.Header,54 headerStyle: o.HeaderStyle.ToLipgloss(),feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
line 55why, one step back55 padding: []int{top, right, bottom, left},refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 56–59why, one step back56 autoWidth: o.Width < 1,57 showHelp: o.ShowHelp,58 help: help.New(),59 keymap: defaultKeymap(),feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952
lines 60–69why, one step back60 }6162 ctx, cancel := timeout.Context(o.Timeout)63 defer cancel()6465 p := tea.NewProgram(66 m,67 tea.WithOutput(os.Stderr),68 tea.WithContext(ctx),69 )refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 70why, one step back70 tm, err := p.Run()feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 71why, one step back71 if err != nil {refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 72why, one step back72 return fmt.Errorf("failed to run input: %w", err)feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 73–74why, one step back73 }74feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952
line 75why, one step back75 m = tm.(model)feat(choose,confirm,file,filter,input,table,write): esc exit 1, ctrl+c exit 130, help arrow order (#771)Carlos Alexandro Beckerbefore adoption774667a
lines 76–78why, one step back76 if !m.submitted {77 return errors.New("not submitted")78 }refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 79why, one step back79 fmt.Println(m.textinput.Value())feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 80–81why, one step back80 return nil81}