From 33f6a40ec035111bc11d5fd5304cac1359af44e0 Mon Sep 17 00:00:00 2001 From: Hsn <62262441+GreedyC@users.noreply.github.com> Date: Fri, 2 Oct 2026 12:30:47 +0300 Subject: [PATCH] docs: fix command and environment godoc examples (#1833) --- color.go | 9 +++++---- commands.go | 6 +++--- options.go | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/color.go b/color.go index d55fea4b..455b4216 100644 --- a/color.go +++ b/color.go @@ -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 } diff --git a/commands.go b/commands.go index 4497c3a3..a2c0e143 100644 --- a/commands.go +++ b/commands.go @@ -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) } diff --git a/options.go b/options.go index b4bd1b9a..06b38056 100644 --- a/options.go +++ b/options.go @@ -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