refactor: change model structure of show users for testing

This commit is contained in:
Slug-Boi
2024-10-24 20:47:53 +02:00
parent b0a5125113
commit fbfde5999f
+17 -6
View File
@@ -82,7 +82,18 @@ func (e example) helpView() string {
return helpStyle_us("\n ↑/↓: Navigate • q: Quit\n") return helpStyle_us("\n ↑/↓: Navigate • q: Quit\n")
} }
func Entry_US(author_file string) { func intialModel_US(author_file string) tea.Model {
loadData(author_file)
model, err := newExample()
if err != nil {
fmt.Println("Could not initialize Bubble Tea model:", err)
os.Exit(1)
}
return model
}
func loadData(author_file string) {
file, err := os.Open(author_file) file, err := os.Open(author_file)
if err != nil { if err != nil {
fmt.Println("Could not open file:", err) fmt.Println("Could not open file:", err)
@@ -103,11 +114,11 @@ func Entry_US(author_file string) {
content = cnt.String() content = cnt.String()
model, err := newExample() }
if err != nil {
fmt.Println("Could not initialize Bubble Tea model:", err) func Entry_US(author_file string) {
os.Exit(1)
} model := intialModel_US(author_file)
if _, err := tea.NewProgram(model).Run(); err != nil { if _, err := tea.NewProgram(model).Run(); err != nil {
fmt.Println("Bummer, there's been an error:", err) fmt.Println("Bummer, there's been an error:", err)