Skip to content
Myr

chore: rename StartReturningModel to Run

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

Added aliases for the old functions, but deprecated them.

authored by Christian Muehlhaeuser · committed by Christian Muehlhaeuser · parent 22d15ef · Browse files · 47 files+66 added−56 removed
This commit

State

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

Diff stats

47 files+66 added−56 removed

  • other:+66 added−56 removed

47 files+66 added−56 removed

modified:examples/altscreen-toggle/main.go+1 added-1 removed
64 unmodified lines
65 help(" space: switch modes • q: exit\n")66}6768func main() {69 if err := tea.NewProgram(model{}).Start(); err != nil {69 if _, err := tea.NewProgram(model{}).Run(); err != nil {70 fmt.Println("Error running program:", err)71 os.Exit(1)72 }73}
modified:examples/chat/main.go+1 added-1 removed
15 unmodified lines
1617func main() {18 p := tea.NewProgram(initialModel())1920 if err := p.Start(); err != nil {20 if _, err := p.Run(); err != nil {21 log.Fatal(err)22 }23}24
85 unmodified lines
modified:examples/composable-views/main.go+1 added-1 removed
154 unmodified lines
155156func main() {157 p := tea.NewProgram(newModel(defaultTime))158159 if err := p.Start(); err != nil {159 if _, err := p.Run(); err != nil {160 log.Fatal(err)161 }162}
modified:examples/credit-card-form/main.go+1 added-1 removed
12 unmodified lines
1314func main() {15 p := tea.NewProgram(initialModel())1617 if err := p.Start(); err != nil {17 if _, err := p.Run(); err != nil {18 log.Fatal(err)19 }20}21
180 unmodified lines
modified:examples/debounce/main.go+1 added-1 removed
57 unmodified lines
58 "\nTo exit press any key, then wait for one second without pressing anything."59}6061func main() {62 if err := tea.NewProgram(model{}).Start(); err != nil {62 if _, err := tea.NewProgram(model{}).Run(); err != nil {63 fmt.Println("uh oh:", err)64 os.Exit(1)65 }66}
modified:examples/exec/main.go+1 added-1 removed
62 unmodified lines
63}6465func main() {66 m := model{}67 if err := tea.NewProgram(m).Start(); err != nil {67 if _, err := tea.NewProgram(m).Run(); err != nil {68 fmt.Println("Error running program:", err)69 os.Exit(1)70 }71}
modified:examples/fullscreen/main.go+1 added-1 removed
15 unmodified lines
16type tickMsg time.Time1718func main() {19 p := tea.NewProgram(model(5), tea.WithAltScreen())20 if err := p.Start(); err != nil {20 if _, err := p.Run(); err != nil {21 log.Fatal(err)22 }23}24
32 unmodified lines
modified:examples/glamour/main.go+1 added-1 removed
118 unmodified lines
119 fmt.Println("Could not initialize Bubble Tea model:", err)120 os.Exit(1)121 }122123 if err := tea.NewProgram(model).Start(); err != nil {123 if _, err := tea.NewProgram(model).Run(); err != nil {124 fmt.Println("Bummer, there's been an error:", err)125 os.Exit(1)126 }127}
modified:examples/help/main.go+1 added-1 removed
138 unmodified lines
139 defer f.Close()140 }141 }142143 if err := tea.NewProgram(newModel()).Start(); err != nil {143 if _, err := tea.NewProgram(newModel()).Run(); err != nil {144 fmt.Printf("Could not start program :(\n%v\n", err)145 os.Exit(1)146 }147}
modified:examples/http/main.go+1 added-1 removed
24 unmodified lines
25func (e errMsg) Error() string { return e.error.Error() }2627func main() {28 p := tea.NewProgram(model{})29 if err := p.Start(); err != nil {29 if _, err := p.Run(); err != nil {30 log.Fatal(err)31 }32}33
49 unmodified lines
modified:examples/list-default/main.go+1 added-1 removed
77 unmodified lines
78 m.list.Title = "My Fave Things"7980 p := tea.NewProgram(m, tea.WithAltScreen())8182 if err := p.Start(); err != nil {82 if _, err := p.Run(); err != nil {83 fmt.Println("Error running program:", err)84 os.Exit(1)85 }86}
modified:examples/list-fancy/main.go+1 added-1 removed
181 unmodified lines
182183func main() {184 rand.Seed(time.Now().UTC().UnixNano())185186 if err := tea.NewProgram(newModel()).Start(); err != nil {186 if _, err := tea.NewProgram(newModel()).Run(); err != nil {187 fmt.Println("Error running program:", err)188 os.Exit(1)189 }190}
modified:examples/list-simple/main.go+1 added-1 removed
118 unmodified lines
119 l.Styles.HelpStyle = helpStyle120121 m := model{list: l}122123 if err := tea.NewProgram(m).Start(); err != nil {123 if _, err := tea.NewProgram(m).Run(); err != nil {124 fmt.Println("Error running program:", err)125 os.Exit(1)126 }127}
modified:examples/mouse/main.go+1 added-1 removed
10 unmodified lines
11)1213func main() {14 p := tea.NewProgram(model{}, tea.WithAltScreen(), tea.WithMouseAllMotion())15 if err := p.Start(); err != nil {15 if _, err := p.Run(); err != nil {16 log.Fatal(err)17 }18}19
34 unmodified lines
modified:examples/package-manager/main.go+1 added-1 removed
129 unmodified lines
130131func main() {132 rand.Seed(time.Now().Unix())133134 if err := tea.NewProgram(newModel()).Start(); err != nil {134 if _, err := tea.NewProgram(newModel()).Run(); err != nil {135 fmt.Println("Error running program:", err)136 os.Exit(1)137 }138}
modified:examples/pager/main.go+1 added-1 removed
139 unmodified lines
140 tea.WithAltScreen(), // use the full size of the terminal in its "alternate screen buffer"141 tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel142 )143144 if err := p.Start(); err != nil {144 if _, err := p.Run(); err != nil {145 fmt.Println("could not run program:", err)146 os.Exit(1)147 }148}
modified:examples/paginator/main.go+1 added-1 removed
68 unmodified lines
69}7071func main() {72 p := tea.NewProgram(newModel())73 if err := p.Start(); err != nil {73 if _, err := p.Run(); err != nil {74 log.Fatal(err)75 }76}
modified:examples/pipe/main.go+1 added-1 removed
43 unmodified lines
44 }4546 model := newModel(strings.TrimSpace(b.String()))4748 if err := tea.NewProgram(model).Start(); err != nil {48 if _, err := tea.NewProgram(model).Run(); err != nil {49 fmt.Println("Couldn't start program:", err)50 os.Exit(1)51 }52}
41 unmodified lines
modified:examples/progress-animated/main.go+1 added-1 removed
28 unmodified lines
29 m := model{30 progress: progress.New(progress.WithDefaultGradient()),31 }3233 if err := tea.NewProgram(m).Start(); err != nil {33 if _, err := tea.NewProgram(m).Run(); err != nil {34 fmt.Println("Oh no!", err)35 os.Exit(1)36 }37}
56 unmodified lines
modified:examples/progress-download/main.go+1 added-1 removed
98 unmodified lines
99100 // Start the download101 go pw.Start()102103 if err := p.Start(); err != nil {103 if _, err := p.Run(); err != nil {104 fmt.Println("error running program:", err)105 os.Exit(1)106 }107}
modified:examples/progress-static/main.go+1 added-1 removed
35 unmodified lines
3637func main() {38 prog := progress.New(progress.WithScaledGradient("#FF7CCB", "#FDFF8C"))3940 if err := tea.NewProgram(model{progress: prog}).Start(); err != nil {40 if _, err := tea.NewProgram(model{progress: prog}).Run(); err != nil {41 fmt.Println("Oh no!", err)42 os.Exit(1)43 }44}
49 unmodified lines
modified:examples/realtime/main.go+2 added-2 removed
83 unmodified lines
84 sub: make(chan struct{}),85 spinner: spinner.New(),86 })8788 if p.Start() != nil {89 fmt.Println("could not start program")88 if _, err := p.Run(); err != nil {89 fmt.Println("could not start program:", err)90 os.Exit(1)91 }92}
modified:examples/result/main.go+2 added-2 removed
70 unmodified lines
7172func main() {73 p := tea.NewProgram(model{})7475 // StartReturningModel returns the model as a tea.Model.76 m, err := p.StartReturningModel()75 // Run returns the model as a tea.Model.76 m, err := p.Run()77 if err != nil {78 fmt.Println("Oh no:", err)79 os.Exit(1)80 }
6 unmodified lines
modified:examples/send-msg/main.go+1 added-1 removed
115 unmodified lines
116 p.Send(resultMsg{food: randomFood(), duration: pause})117 }118 }()119120 if err := p.Start(); err != nil {120 if _, err := p.Run(); err != nil {121 fmt.Println("Error running program:", err)122 os.Exit(1)123 }124}
9 unmodified lines
modified:examples/sequence/main.go+1 added-1 removed
31 unmodified lines
32 return ""33}3435func main() {36 if err := tea.NewProgram(model{}).Start(); err != nil {36 if _, err := tea.NewProgram(model{}).Run(); err != nil {37 fmt.Println("Uh oh:", err)38 os.Exit(1)39 }40}
modified:examples/simple/main.go+1 added-1 removed
21 unmodified lines
22 }2324 // Initialize our program25 p := tea.NewProgram(model(5))26 if err := p.Start(); err != nil {26 if _, err := p.Run(); err != nil {27 log.Fatal(err)28 }29}30
42 unmodified lines
modified:examples/spinner/main.go+1 added-1 removed
64 unmodified lines
65}6667func main() {68 p := tea.NewProgram(initialModel())69 if err := p.Start(); err != nil {69 if _, err := p.Run(); err != nil {70 fmt.Println(err)71 os.Exit(1)72 }73}
modified:examples/spinners/main.go+1 added-1 removed
30 unmodified lines
31func main() {32 m := model{}33 m.resetSpinner()3435 if err := tea.NewProgram(m).Start(); err != nil {35 if _, err := tea.NewProgram(m).Run(); err != nil {36 fmt.Println("could not run program:", err)37 os.Exit(1)38 }39}
61 unmodified lines
modified:examples/split-editors/main.go+1 added-1 removed
195 unmodified lines
196 return lipgloss.JoinHorizontal(lipgloss.Top, views...) + "\n\n" + help197}198199func main() {200 if err := tea.NewProgram(newModel(), tea.WithAltScreen()).Start(); err != nil {200 if _, err := tea.NewProgram(newModel(), tea.WithAltScreen()).Run(); err != nil {201 fmt.Println("Error while running program:", err)202 os.Exit(1)203 }204}
modified:examples/stopwatch/main.go+1 added-1 removed
94 unmodified lines
95 }9697 m.keymap.start.SetEnabled(false)9899 if err := tea.NewProgram(m).Start(); err != nil {99 if _, err := tea.NewProgram(m).Run(); err != nil {100 fmt.Println("Oh no, it didn't work:", err)101 os.Exit(1)102 }103}
modified:examples/table/main.go+1 added-1 removed
175 unmodified lines
176 Bold(false)177 t.SetStyles(s)178179 m := model{t}180 if err := tea.NewProgram(m).Start(); err != nil {180 if _, err := tea.NewProgram(m).Run(); err != nil {181 fmt.Println("Error running program:", err)182 os.Exit(1)183 }184}
modified:examples/tabs/main.go+1 added-1 removed
91 unmodified lines
92func main() {93 tabs := []string{"Lip Gloss", "Blush", "Eye Shadow", "Mascara", "Foundation"}94 tabContent := []string{"Lip Gloss Tab", "Blush Tab", "Eye Shadow Tab", "Mascara Tab", "Foundation Tab"}95 m := model{Tabs: tabs, TabContent: tabContent}96 if err := tea.NewProgram(m).Start(); err != nil {96 if _, err := tea.NewProgram(m).Run(); err != nil {97 fmt.Println("Error running program:", err)98 os.Exit(1)99 }100}
14 unmodified lines
modified:examples/textarea/main.go+1 added-1 removed
12 unmodified lines
1314func main() {15 p := tea.NewProgram(initialModel())1617 if err := p.Start(); err != nil {17 if _, err := p.Run(); err != nil {18 log.Fatal(err)19 }20}21
60 unmodified lines
modified:examples/textinput/main.go+1 added-2 removed
11 unmodified lines
12)1314func main() {15 p := tea.NewProgram(initialModel())1617 if err := p.Start(); err != nil {16 if _, err := p.Run(); err != nil {17 log.Fatal(err)18 }19}20
53 unmodified lines
modified:examples/textinputs/main.go+1 added-1 removed
168 unmodified lines
169 return b.String()170}171172func main() {173 if err := tea.NewProgram(initialModel()).Start(); err != nil {173 if _, err := tea.NewProgram(initialModel()).Run(); err != nil {174 fmt.Printf("could not start program: %s\n", err)175 os.Exit(1)176 }177}
modified:examples/timer/main.go+1 added-1 removed
113 unmodified lines
114 help: help.NewModel(),115 }116 m.keymap.start.SetEnabled(false)117118 if err := tea.NewProgram(m).Start(); err != nil {118 if _, err := tea.NewProgram(m).Run(); err != nil {119 fmt.Println("Uh oh, we encountered an error:", err)120 os.Exit(1)121 }122}
modified:examples/tui-daemon-combo/main.go+1 added-1 removed
43 unmodified lines
44 log.SetOutput(ioutil.Discard)45 }4647 p := tea.NewProgram(newModel(), opts...)48 if err := p.Start(); err != nil {48 if _, err := p.Run(); err != nil {49 fmt.Println("Error starting Bubble Tea program:", err)50 os.Exit(1)51 }52}
87 unmodified lines
modified:examples/views/main.go+1 added-1 removed
39 unmodified lines
4041func main() {42 initialModel := model{0, false, 10, 0, 0, false, false}43 p := tea.NewProgram(initialModel)44 if err := p.Start(); err != nil {44 if _, err := p.Run(); err != nil {45 fmt.Println("could not start program:", err)46 }47}48
241 unmodified lines
modified:tutorials/basics/main.go+1 added-1 removed
77 unmodified lines
78}7980func main() {81 p := tea.NewProgram(initialModel())82 if err := p.Start(); err != nil {82 if _, err := p.Run(); err != nil {83 fmt.Printf("Alas, there's been an error: %v", err)84 os.Exit(1)85 }86}
modified:tutorials/basics/README.md+1 added-1 removed
198 unmodified lines
199200```go201func main() {202 p := tea.NewProgram(initialModel())203 if err := p.Start(); err != nil {203 if _, err := p.Run(); err != nil {204 fmt.Printf("Alas, there's been an error: %v", err)205 os.Exit(1)206 }207}
35 unmodified lines
modified:tutorials/commands/main.go+1 added-1 removed
69 unmodified lines
70 return "\n" + s + "\n\n"71}7273func main() {74 if err := tea.NewProgram(model{}).Start(); err != nil {74 if _, err := tea.NewProgram(model{}).Run(); err != nil {75 fmt.Printf("Uh oh, there was an error: %v\n", err)76 os.Exit(1)77 }78}
modified:tutorials/commands/README.md+1 added-1 removed
167 unmodified lines
168as a `struct` with defaults.169170```go171func main() {172 if err := tea.NewProgram(model{}).Start(); err != nil {172 if _, err := tea.NewProgram(model{}).Run(); err != nil {173 fmt.Printf("Uh oh, there was an error: %v\n", err)174 os.Exit(1)175 }176}
71 unmodified lines
modified:exec_test.go+1 added-1 removed
36 unmodified lines
37 var in bytes.Buffer3839 m := &testExecModel{}40 p := NewProgram(m, WithInput(&in), WithOutput(&buf))41 if err := p.Start(); err != nil {41 if _, err := p.Run(); err != nil {42 t.Fatal(err)43 }4445 if m.err != nil {
3 unmodified lines
modified:options.go+1 added-1 removed
61 unmodified lines
62//63// Example:64//65// p := tea.NewProgram(Model{}, tea.WithAltScreen())66// if err := p.Start(); err != nil {66// if _, err := p.Run(); err != nil {67// fmt.Println("Error running program:", err)68// os.Exit(1)69// }70//
73 unmodified lines
modified:README.md+1 added-1 removed
237 unmodified lines
238239```go240func main() {241 p := tea.NewProgram(initialModel())242 if err := p.Start(); err != nil {242 if _, err := p.Run(); err != nil {243 fmt.Printf("Alas, there's been an error: %v", err)244 os.Exit(1)245 }246}
150 unmodified lines
modified:tea_test.go+3 added-3 removed
32 unmodified lines
33 var in bytes.Buffer34 in.Write([]byte("q"))3536 p := NewProgram(&testModel{}, WithInput(&in), WithOutput(&buf))37 if err := p.Start(); err != nil {37 if _, err := p.Run(); err != nil {38 t.Fatal(err)39 }4041 if buf.Len() == 0 {
16 unmodified lines
58 }59 }60 }()6162 if err := p.Start(); err != nil {62 if _, err := p.Run(); err != nil {63 t.Fatal(err)64 }65}66
12 unmodified lines
79 }80 }81 }()8283 if err := p.Start(); err != nil {83 if _, err := p.Run(); err != nil {84 t.Fatal(err)85 }86}
modified:tea.go+16 added-5 removed
333 unmodified lines
334 }335 }336}337338// StartReturningModel initializes the program and runs its event loops,339// blocking until it gets terminated by either [Program.Quit], [Program.Kill],340// or its signal handler. Returns the final model.341func (p *Program) StartReturningModel() (Model, error) {338// Run initializes the program and runs its event loops, blocking until it gets339// terminated by either [Program.Quit], [Program.Kill], or its signal handler.340// Returns the final model.341func (p *Program) Run() (Model, error) {342 handlers := handlers{}343 cmds := make(chan Cmd)344 p.errs = make(chan error)345
128 unmodified lines
474475 return model, err476}477478// StartReturningModel initializes the program and runs its event loops,479// blocking until it gets terminated by either [Program.Quit], [Program.Kill],480// or its signal handler. Returns the final model.481//482// Deprecated: please use [Program.Run] instead.483func (p *Program) StartReturningModel() (Model, error) {484 return p.Run()485}486487// Start initializes the program and runs its event loops, blocking until it488// gets terminated by either [Program.Quit], [Program.Kill], or its signal489// handler.490//491// Deprecated: please use [Program.Run] instead.492func (p *Program) Start() error {482 _, err := p.StartReturningModel()493 _, err := p.Run()494 return err495}496497// Send sends a message to the main update function, effectively allowing
127 unmodified lines