docs: fix command and environment godoc examples (#1833)
This commit is contained in:
parent
ff51ba4c51
commit
33f6a40ec0
3 changed files with 9 additions and 8 deletions
9
color.go
9
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 }
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue