Skip to content
Myr

docs: fix command and environment godoc examples (#1833)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Hsn · committed by GitHub · parent ff51ba4 · Browse files · 3 files+9 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+9 added−8 removed

  • other:+9 added−8 removed

3 files+9 added−8 removed

modified:color.go+5 added-4 removed
50 unmodified lines
51// BackgroundColorMsg represents a background color message. This message is52// emitted when the program requests the terminal background color with the53// [RequestBackgroundColor] Cmd.54//55// This is commonly used in [Update.Init] to get the terminal background color55// This is commonly used in [Model.Init] to get the terminal background color56// for style definitions. For that you'll want to call57// [BackgroundColorMsg.IsDark] to determine if the color is dark or light. For58// example:59//60// func (m Model) Init() Cmd {61// return RequestBackgroundColor()60// func (m model) Init() Cmd {61// return RequestBackgroundColor62// }63//64// func (m Model) Update(msg Msg) (Model, Cmd) {64// func (m model) Update(msg Msg) (Model, Cmd) {65// switch msg := msg.(type) {66// case BackgroundColorMsg:67// m.styles = newStyles(msg.IsDark())68// }69// return m, nil70// }71type BackgroundColorMsg struct{ color.Color }7273// String returns the hex representation of the color.
22 unmodified lines
modified:commands.go+3 added-3 removed
7 unmodified lines
8// about the results. Use a Batch to return several commands.9//10// Example:11//12// func (m model) Init() (Model, Cmd) {13// return m, tea.Batch(someCommand, someOtherCommand)14// }12// func (m model) Init() tea.Cmd {13// return tea.Batch(someCommand, someOtherCommand)14// }15func Batch(cmds ...Cmd) Cmd {16 return compactCmds[BatchMsg](cmds)17}18
157 unmodified lines
modified:options.go+1 added-1 removed
59 unmodified lines
60//61// var sess ssh.Session // ssh.Session is a type from the github.com/charmbracelet/ssh package62// pty, _, _ := sess.Pty()63// environ := append(sess.Environ(), "TERM="+pty.Term)64// p := tea.NewProgram(model, tea.WithEnvironment(environ)64// p := tea.NewProgram(model, tea.WithEnvironment(environ))65func WithEnvironment(env []string) ProgramOption {66 return func(p *Program) {67 p.environ = env68 }
107 unmodified lines