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
Provenance
- Commit
6b77c8f- Tree
75dc5a9- Author
Christian Muehlhaeuser <muesli@gmail.com>- Committer
Christian Muehlhaeuser <muesli@gmail.com>- Parent
22d15ef
47 files changed+66 added−56 removed
modified:examples/altscreen-toggle/main.go+1 added-1 removed
64 unmodified lines65 help(" space: switch modes • q: exit\n")66 }67 68 func 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 lines16 17 func main() {18 p := tea.NewProgram(initialModel())19 20- if err := p.Start(); err != nil {20+ if _, err := p.Run(); err != nil {21 log.Fatal(err)22 }23 }24 85 unmodified linesmodified:examples/composable-views/main.go+1 added-1 removed
154 unmodified lines155 156 func main() {157 p := tea.NewProgram(newModel(defaultTime))158 159- 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 lines13 14 func main() {15 p := tea.NewProgram(initialModel())16 17- if err := p.Start(); err != nil {17+ if _, err := p.Run(); err != nil {18 log.Fatal(err)19 }20 }21 180 unmodified linesmodified:examples/debounce/main.go+1 added-1 removed
57 unmodified lines58 "\nTo exit press any key, then wait for one second without pressing anything."59 }60 61 func 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 lines63 }64 65 func 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 lines16 type tickMsg time.Time17 18 func 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 linesmodified:examples/glamour/main.go+1 added-1 removed
118 unmodified lines119 fmt.Println("Could not initialize Bubble Tea model:", err)120 os.Exit(1)121 }122 123- 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 lines139 defer f.Close()140 }141 }142 143- 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 lines25 func (e errMsg) Error() string { return e.error.Error() }26 27 func 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 linesmodified:examples/list-default/main.go+1 added-1 removed
77 unmodified lines78 m.list.Title = "My Fave Things"79 80 p := tea.NewProgram(m, tea.WithAltScreen())81 82- 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 lines182 183 func main() {184 rand.Seed(time.Now().UTC().UnixNano())185 186- 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 lines119 l.Styles.HelpStyle = helpStyle120 121 m := model{list: l}122 123- 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 lines11 )12 13 func 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 linesmodified:examples/package-manager/main.go+1 added-1 removed
129 unmodified lines130 131 func main() {132 rand.Seed(time.Now().Unix())133 134- 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 lines140 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 )143 144- 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 lines69 }70 71 func 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 lines44 }45 46 model := newModel(strings.TrimSpace(b.String()))47 48- 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 linesmodified:examples/progress-animated/main.go+1 added-1 removed
28 unmodified lines29 m := model{30 progress: progress.New(progress.WithDefaultGradient()),31 }32 33- 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 linesmodified:examples/progress-download/main.go+1 added-1 removed
98 unmodified lines99 100 // Start the download101 go pw.Start()102 103- 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 lines36 37 func main() {38 prog := progress.New(progress.WithScaledGradient("#FF7CCB", "#FDFF8C"))39 40- 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 linesmodified:examples/realtime/main.go+2 added-2 removed
83 unmodified lines84 sub: make(chan struct{}),85 spinner: spinner.New(),86 })87 88- 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 lines71 72 func main() {73 p := tea.NewProgram(model{})74 75- // 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 linesmodified:examples/send-msg/main.go+1 added-1 removed
115 unmodified lines116 p.Send(resultMsg{food: randomFood(), duration: pause})117 }118 }()119 120- 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 linesmodified:examples/sequence/main.go+1 added-1 removed
31 unmodified lines32 return ""33 }34 35 func 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 lines22 }23 24 // 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 linesmodified:examples/spinner/main.go+1 added-1 removed
64 unmodified lines65 }66 67 func 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 lines31 func main() {32 m := model{}33 m.resetSpinner()34 35- 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 linesmodified:examples/split-editors/main.go+1 added-1 removed
195 unmodified lines196 return lipgloss.JoinHorizontal(lipgloss.Top, views...) + "\n\n" + help197 }198 199 func 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 lines95 }96 97 m.keymap.start.SetEnabled(false)98 99- 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 lines176 Bold(false)177 t.SetStyles(s)178 179 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 lines92 func 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 linesmodified:examples/textarea/main.go+1 added-1 removed
12 unmodified lines13 14 func main() {15 p := tea.NewProgram(initialModel())16 17- if err := p.Start(); err != nil {17+ if _, err := p.Run(); err != nil {18 log.Fatal(err)19 }20 }21 60 unmodified linesmodified:examples/textinput/main.go+1 added-2 removed
11 unmodified lines12 )13 14 func main() {15 p := tea.NewProgram(initialModel())16-17- if err := p.Start(); err != nil {16+ if _, err := p.Run(); err != nil {17 log.Fatal(err)18 }19 }20 53 unmodified linesmodified:examples/textinputs/main.go+1 added-1 removed
168 unmodified lines169 return b.String()170 }171 172 func 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 lines114 help: help.NewModel(),115 }116 m.keymap.start.SetEnabled(false)117 118- 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 lines44 log.SetOutput(ioutil.Discard)45 }46 47 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 linesmodified:examples/views/main.go+1 added-1 removed
39 unmodified lines40 41 func 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 linesmodified:tutorials/basics/main.go+1 added-1 removed
77 unmodified lines78 }79 80 func 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 lines199 200 ```go201 func 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 linesmodified:tutorials/commands/main.go+1 added-1 removed
69 unmodified lines70 return "\n" + s + "\n\n"71 }72 73 func 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 lines168 as a `struct` with defaults.169 170 ```go171 func 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 linesmodified:exec_test.go+1 added-1 removed
36 unmodified lines37 var in bytes.Buffer38 39 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 }44 45 if m.err != nil {3 unmodified linesmodified:options.go+1 added-1 removed
61 unmodified lines62 //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 linesmodified:README.md+1 added-1 removed
237 unmodified lines238 239 ```go240 func 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 linesmodified:tea_test.go+3 added-3 removed
32 unmodified lines33 var in bytes.Buffer34 in.Write([]byte("q"))35 36 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 }40 41 if buf.Len() == 0 {16 unmodified lines58 }59 }60 }()61 62- if err := p.Start(); err != nil {62+ if _, err := p.Run(); err != nil {63 t.Fatal(err)64 }65 }66 12 unmodified lines79 }80 }81 }()82 83- 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 lines334 }335 }336 }337 338-// 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.341-func (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.341+func (p *Program) Run() (Model, error) {342 handlers := handlers{}343 cmds := make(chan Cmd)344 p.errs = make(chan error)345 128 unmodified lines474 475 return model, err476 }477 478+// 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.483+func (p *Program) StartReturningModel() (Model, error) {484+ return p.Run()485+}486+487 // 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.492 func (p *Program) Start() error {482- _, err := p.StartReturningModel()493+ _, err := p.Run()494 return err495 }496 497 // Send sends a message to the main update function, effectively allowing127 unmodified lines