Skip to content
Myr

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 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 write
23import (

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 back
4 "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 back
5 "fmt"

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

line 6why, one step back
6 "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 back
7 "strings"
8

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

lines 9–11why, one step back
9 "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 back
12 "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 back
16)
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 back
21 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 back
22 if in != "" && o.Value == "" {
23 o.Value = strings.ReplaceAll(in, "\r", "")24 }25

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

lines 26–27why, one step back
26 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 back
28

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

lines 29–32why, one step back
29 a.Prompt = o.Prompt
30 a.Placeholder = o.Placeholder31 a.ShowLineNumbers = o.ShowLineNumbers32 a.CharLimit = o.CharLimit

fix(write): max height, max chars (#753)Carlos Alexandro Beckerbefore adoption01892a0

line 33why, one step back
33 a.MaxHeight = o.MaxLines

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

line 34why, one step back
34 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 back
35

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

line 36why, one step back
36 taStyles := textarea.StyleState{

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

lines 37–44why, one step back
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 }

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

line 45why, one step back
45

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

lines 46–50why, one step back
46 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 back
51

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

lines 52–53why, one step back
52 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 back
54 a.SetValue(o.Value)
55

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

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

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

lines 57–63why, one step back
57 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 back
64 padding: []int{top, right, bottom, left},

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

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

fix(write): ctrl+j not making new line (#819)Carlos Alexandro Beckerbefore adoptionc11af42

lines 67–68why, one step back
67 m.textarea.KeyMap.InsertNewline = m.keymap.InsertNewline
68

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

lines 69–76why, one step back
69 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 back
77 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 back
78 if err != nil {

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

line 79why, one step back
79 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 back
80 }

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

line 81why, one step back
81 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 back
82 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 back
85 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 back
86 return nil
87}