command.go
This file
Path
write/command.go
87 lines · 2.1 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 write23import (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
line 5why, one step back5 "fmt"refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 6why, one step back6 "os"feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 7–8why, one step back7 "strings"8chore: update to bubbletea v2 (#1112)Drew Smirnoffbefore adoptionf6dd28e
lines 9–11why, one step back9 "charm.land/bubbles/v2/help"10 "charm.land/bubbles/v2/textarea"11 tea "charm.land/bubbletea/v2"chore: prepare v2 (#1116)Drew Smirnoffbefore adoption02d6f06
lines 12–15why, one step back12 "charm.land/gum/v2/cursor"13 "charm.land/gum/v2/internal/stdin"14 "charm.land/gum/v2/internal/timeout"15 "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 16–20why, one step back16)1718// Run provides a shell script interface for the text area bubble.19// https://github.com/charmbracelet/bubbles/textarea20func (o Options) Run() error {feat: --no-strip-ansi (#784)Carlos Alexandro Beckerbefore adoption4cedf9f
line 21why, one step back21 in, _ := stdin.Read(stdin.StripANSI(o.StripANSI))feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 22–25why, one step back22 if in != "" && o.Value == "" {23 o.Value = strings.ReplaceAll(in, "\r", "")24 }25refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 26–27why, one step back26 a := textarea.New()27 a.Focus()feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 28why, one step back28refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 29–32why, one step back29 a.Prompt = o.Prompt30 a.Placeholder = o.Placeholder31 a.ShowLineNumbers = o.ShowLineNumbers32 a.CharLimit = o.CharLimitfix(write): max height, max chars (#753)Carlos Alexandro Beckerbefore adoption01892a0
line 33why, one step back33 a.MaxHeight = o.MaxLinesfeat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
line 34why, one step back34 top, right, bottom, left := style.ParsePadding(o.Padding)feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 35why, one step back35chore: update to bubbletea v2 (#1112)Drew Smirnoffbefore adoptionf6dd28e
line 36why, one step back36 taStyles := textarea.StyleState{refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 37–44why, one step back37 Base: o.BaseStyle.ToLipgloss(),38 Placeholder: o.PlaceholderStyle.ToLipgloss(),39 CursorLine: o.CursorLineStyle.ToLipgloss(),40 CursorLineNumber: o.CursorLineNumberStyle.ToLipgloss(),41 EndOfBuffer: o.EndOfBufferStyle.ToLipgloss(),42 LineNumber: o.LineNumberStyle.ToLipgloss(),43 Prompt: o.PromptStyle.ToLipgloss(),44 }feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 45why, one step back45chore: update to bubbletea v2 (#1112)Drew Smirnoffbefore adoptionf6dd28e
lines 46–50why, one step back46 styles := a.Styles()47 styles.Focused = taStyles48 styles.Blurred = taStyles49 a.SetStyles(styles)50 cursor.TextArea(&a, o.CursorMode, o.CursorStyle)feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 51why, one step back51feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
lines 52–53why, one step back52 a.SetWidth(max(0, o.Width-left-right))53 a.SetHeight(max(0, o.Height-top-bottom))refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 54–55why, one step back54 a.SetValue(o.Value)55feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952
line 56why, one step back56 m := model{refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 57–63why, one step back57 textarea: a,58 header: o.Header,59 headerStyle: o.HeaderStyle.ToLipgloss(),60 autoWidth: o.Width < 1,61 help: help.New(),62 showHelp: o.ShowHelp,63 keymap: defaultKeymap(),feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
line 64why, one step back64 padding: []int{top, right, bottom, left},feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952
lines 65–66why, one step back65 }66fix(write): ctrl+j not making new line (#819)Carlos Alexandro Beckerbefore adoptionc11af42
lines 67–68why, one step back67 m.textarea.KeyMap.InsertNewline = m.keymap.InsertNewline68feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952
lines 69–76why, one step back69 ctx, cancel := timeout.Context(o.Timeout)70 defer cancel()7172 p := tea.NewProgram(73 m,74 tea.WithOutput(os.Stderr),75 tea.WithContext(ctx),76 )refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 77why, one step back77 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 78why, one step back78 if err != nil {refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 79why, one step back79 return fmt.Errorf("failed to run write: %w", err)feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 80why, one step back80 }feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952
line 81why, one step back81 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 82–84why, one step back82 if !m.submitted {83 return errors.New("not submitted")84 }refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 85why, one step back85 fmt.Println(m.textarea.Value())feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 86–87why, one step back86 return nil87}