feat: implement initial BrewMaster TUI skeleton
Co-authored-by: aider (ollama_chat/gemma4:31b) <aider@aider.chat>
This commit is contained in:
8
go.mod
Normal file
8
go.mod
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
module brewmaster
|
||||||
|
|
||||||
|
go 1.21
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/gdamore/tcell/v2 v2.7.0
|
||||||
|
github.com/rivo/tview v0.0.0-20231011143503-311331111111
|
||||||
|
)
|
||||||
67
main.go
Normal file
67
main.go
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
|
"github.com/gdamore/tcell/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Brew struct {
|
||||||
|
Name string
|
||||||
|
Status string
|
||||||
|
Progress string
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
app := tview.NewApplication()
|
||||||
|
|
||||||
|
// Mock data for active brews
|
||||||
|
brews := []Brew{
|
||||||
|
{Name: "Belgian Tripel", Status: "Fermenting", Progress: "60%"},
|
||||||
|
{Name: "West Coast IPA", Status: "Boiling", Progress: "20%"},
|
||||||
|
{Name: "Imperial Stout", Status: "Conditioning", Progress: "90%"},
|
||||||
|
{Name: "Saison", Status: "Mashing", Progress: "10%"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Header
|
||||||
|
header := tview.NewTextView().
|
||||||
|
SetTextAlign(tview.AlignCenter).
|
||||||
|
SetText(" BrewMaster - Active Brews Dashboard ")
|
||||||
|
header.SetBorder(true).SetBorderColor(tcell.ColorYellow)
|
||||||
|
|
||||||
|
// Table for brews
|
||||||
|
table := tview.NewTable().
|
||||||
|
SetBorders(true).
|
||||||
|
SetSelectable(true, false)
|
||||||
|
|
||||||
|
// Set table headers
|
||||||
|
headers := []string{"Beer Name", "Status", "Progress"}
|
||||||
|
for i, h := range headers {
|
||||||
|
table.SetCell(0, i, tview.NewTableCell(h).SetTextColor(tcell.ColorYellow).SetSelectable(false))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate table with mock data
|
||||||
|
for i, brew := range brews {
|
||||||
|
row := i + 1
|
||||||
|
table.SetCell(row, 0, tview.NewTableCell(brew.Name))
|
||||||
|
table.SetCell(row, 1, tview.NewTableCell(brew.Status))
|
||||||
|
table.SetCell(row, 2, tview.NewTableCell(brew.Progress))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Footer
|
||||||
|
footer := tview.NewTextView().
|
||||||
|
SetTextAlign(tview.AlignCenter).
|
||||||
|
SetText(" Press Ctrl+C to exit ")
|
||||||
|
|
||||||
|
// Layout: Vertical flex
|
||||||
|
flex := tview.NewFlex().
|
||||||
|
SetDirection(tview.FlexRow).
|
||||||
|
AddItem(header, 1, 1, false).
|
||||||
|
AddItem(table, 0, 1, true).
|
||||||
|
AddItem(footer, 1, 1, false)
|
||||||
|
|
||||||
|
if err := app.SetRoot(flex, true).Run(); err != nil {
|
||||||
|
fmt.Printf("Error running application: %v\n", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user