f922b855eb
Reimplement the TUI in Go using Bubble Tea, replacing the Kotlin/Tamboui app. Same WebSocket protocol, soft-rounded layout with blue accent theme.
32 lines
734 B
Go
32 lines
734 B
Go
// Command tui is the correx terminal UI: a Bubble Tea client that speaks the
|
|
// correx WebSocket protocol to apps/server.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
"github.com/correx/tui-go/internal/app"
|
|
"github.com/correx/tui-go/internal/ws"
|
|
)
|
|
|
|
func main() {
|
|
host := flag.String("host", "localhost", "server host")
|
|
port := flag.Int("port", 8080, "server port")
|
|
flag.Parse()
|
|
|
|
client := ws.New(*host, *port)
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
go client.Run(ctx)
|
|
|
|
p := tea.NewProgram(app.NewModel(client), tea.WithAltScreen())
|
|
if _, err := p.Run(); err != nil {
|
|
fmt.Fprintln(os.Stderr, "correx tui error:", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|