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

This commit is contained in:
Hsn 2026-10-02 12:30:47 +03:00 committed by GitHub
parent ff51ba4c51
commit 33f6a40ec0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 8 deletions

View file

@ -52,20 +52,21 @@ func (e ForegroundColorMsg) IsDark() bool {
// emitted when the program requests the terminal background color with the
// [RequestBackgroundColor] Cmd.
//
// This is commonly used in [Update.Init] to get the terminal background color
// This is commonly used in [Model.Init] to get the terminal background color
// for style definitions. For that you'll want to call
// [BackgroundColorMsg.IsDark] to determine if the color is dark or light. For
// example:
//
// func (m Model) Init() Cmd {
// return RequestBackgroundColor()
// func (m model) Init() Cmd {
// return RequestBackgroundColor
// }
//
// func (m Model) Update(msg Msg) (Model, Cmd) {
// func (m model) Update(msg Msg) (Model, Cmd) {
// switch msg := msg.(type) {
// case BackgroundColorMsg:
// m.styles = newStyles(msg.IsDark())
// }
// return m, nil
// }
type BackgroundColorMsg struct{ color.Color }

View file

@ -9,9 +9,9 @@ import (
//
// Example:
//
// func (m model) Init() (Model, Cmd) {
// return m, tea.Batch(someCommand, someOtherCommand)
// }
// func (m model) Init() tea.Cmd {
// return tea.Batch(someCommand, someOtherCommand)
// }
func Batch(cmds ...Cmd) Cmd {
return compactCmds[BatchMsg](cmds)
}

View file

@ -61,7 +61,7 @@ func WithInput(input io.Reader) ProgramOption {
// var sess ssh.Session // ssh.Session is a type from the github.com/charmbracelet/ssh package
// pty, _, _ := sess.Pty()
// environ := append(sess.Environ(), "TERM="+pty.Term)
// p := tea.NewProgram(model, tea.WithEnvironment(environ)
// p := tea.NewProgram(model, tea.WithEnvironment(environ))
func WithEnvironment(env []string) ProgramOption {
return func(p *Program) {
p.environ = env