command.go
This file
Path
write/command.go
87 lines · 2.2 KiB · Go
Last changed by
feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
History of this fileTake it
The walk stopped after 200 commits: lines older than 19a93b0 point at it.
refactor(input): simplify echoModeCarlos Alexandro Beckerbefore adoption19a93b0
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"refactor(input): simplify echoModeCarlos Alexandro Beckerbefore adoption19a93b0
line 5why, one step back5 "fmt"refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 6why, one step back6 "os"refactor(input): simplify echoModeCarlos Alexandro Beckerbefore adoption19a93b0
lines 7–8why, one step back7 "strings"8refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 9–12why, one step back9 "github.com/charmbracelet/bubbles/help"10 "github.com/charmbracelet/bubbles/textarea"11 tea "github.com/charmbracelet/bubbletea"12 "github.com/charmbracelet/gum/cursor"refactor(input): simplify echoModeCarlos Alexandro Beckerbefore adoption19a93b0
line 13why, one step back13 "github.com/charmbracelet/gum/internal/stdin"feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952
line 14why, one step back14 "github.com/charmbracelet/gum/internal/timeout"feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
line 15why, one step back15 "github.com/charmbracelet/gum/style"refactor(input): simplify echoModeCarlos Alexandro Beckerbefore adoption19a93b0
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))refactor(input): simplify echoModeCarlos Alexandro Beckerbefore adoption19a93b0
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()refactor(input): simplify echoModeCarlos Alexandro Beckerbefore adoption19a93b0
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)refactor(input): simplify echoModeCarlos Alexandro Beckerbefore adoption19a93b0
line 35why, one step back35refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 36–44why, one step back36 style := textarea.Style{37 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 }refactor(input): simplify echoModeCarlos Alexandro Beckerbefore adoption19a93b0
line 45why, one step back45refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 46–49why, one step back46 a.BlurredStyle = style47 a.FocusedStyle = style48 a.Cursor.Style = o.CursorStyle.ToLipgloss()49 a.Cursor.SetMode(cursor.Modes[o.CursorMode])refactor(input): simplify echoModeCarlos Alexandro Beckerbefore adoption19a93b0
line 50why, one step back50feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
lines 51–52why, one step back51 a.SetWidth(max(0, o.Width-left-right))52 a.SetHeight(max(0, o.Height-top-bottom))refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 53–54why, one step back53 a.SetValue(o.Value)54feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952
line 55why, one step back55 m := model{refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 56–62why, one step back56 textarea: a,57 header: o.Header,58 headerStyle: o.HeaderStyle.ToLipgloss(),59 autoWidth: o.Width < 1,60 help: help.New(),61 showHelp: o.ShowHelp,62 keymap: defaultKeymap(),feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
line 63why, one step back63 padding: []int{top, right, bottom, left},feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952
lines 64–65why, one step back64 }65fix(write): ctrl+j not making new line (#819)Carlos Alexandro Beckerbefore adoptionc11af42
lines 66–67why, one step back66 m.textarea.KeyMap.InsertNewline = m.keymap.InsertNewline67feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952
lines 68–76why, one step back68 ctx, cancel := timeout.Context(o.Timeout)69 defer cancel()7071 p := tea.NewProgram(72 m,73 tea.WithOutput(os.Stderr),74 tea.WithReportFocus(),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()refactor(input): simplify echoModeCarlos Alexandro Beckerbefore adoption19a93b0
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)refactor(input): simplify echoModeCarlos Alexandro Beckerbefore adoption19a93b0
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())refactor(input): simplify echoModeCarlos Alexandro Beckerbefore adoption19a93b0
lines 86–87why, one step back86 return nil87}