feat: TeamSpeak TUI client with Bubble Tea
- Created TUI client in cmd/tui - Implemented channel navigation and user display - Fixed serverInfo initialization in ts3client - Added real-time log panel in TUI - Ordered channels by ID for stability
This commit is contained in:
53
cmd/tui/main.go
Normal file
53
cmd/tui/main.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
// debugLog writes to a debug file
|
||||
var debugFile *os.File
|
||||
|
||||
func debugLog(format string, args ...any) {
|
||||
if debugFile != nil {
|
||||
fmt.Fprintf(debugFile, format+"\n", args...)
|
||||
debugFile.Sync()
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
serverAddr := flag.String("server", "127.0.0.1:9987", "TeamSpeak 3 Server Address")
|
||||
nickname := flag.String("nickname", "TUI-User", "Your nickname")
|
||||
debug := flag.Bool("debug", false, "Enable debug logging to tui-debug.log")
|
||||
flag.Parse()
|
||||
|
||||
// Disable log output completely to prevent TUI corruption
|
||||
log.SetOutput(io.Discard)
|
||||
|
||||
// Enable debug file logging if requested
|
||||
if *debug {
|
||||
var err error
|
||||
debugFile, err = os.Create("tui-debug.log")
|
||||
if err == nil {
|
||||
defer debugFile.Close()
|
||||
debugLog("TUI Debug started")
|
||||
}
|
||||
}
|
||||
|
||||
// Create the TUI model
|
||||
m := NewModel(*serverAddr, *nickname)
|
||||
|
||||
// Create Bubble Tea program
|
||||
p := tea.NewProgram(m, tea.WithAltScreen())
|
||||
|
||||
// Run
|
||||
if _, err := p.Run(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user