Skip to content
Myr

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 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 input
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

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

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

lines 8–10why, one step back
8 "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 back
11 "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 back
15)
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 back
20 if o.Value == "" {

feat: --no-strip-ansi (#784)Carlos Alexandro Beckerbefore adoption4cedf9f

line 21why, one step back
21 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 back
22 o.Value = in
23 }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 back
27 if o.Value != "" {

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

line 28why, one step back
28 i.SetValue(o.Value)

feat: --no-strip-ansi (#784)Carlos Alexandro Beckerbefore adoption4cedf9f

line 29why, one step back
29 } 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 back
30 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 back
31 }

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

lines 32–34why, one step back
32 i.Focus()
33 i.Prompt = o.Prompt34 i.Placeholder = o.Placeholder

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

lines 35–42why, one step back
35 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 back
43 i.CharLimit = o.CharLimit

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

lines 44–45why, one step back
44
45 if o.Password {

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

lines 46–47why, one step back
46 i.EchoMode = textinput.EchoPassword
47 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 back
48 }
49

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

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

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

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

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

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

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

lines 56–59why, one step back
56 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 back
60 }
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 back
70 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 back
71 if err != nil {

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

line 72why, one step back
72 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 back
73 }
74

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

line 75why, one step back
75 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 back
76 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 back
79 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 back
80 return nil
81}