Phase 5: TUI client (Bubbletea)
- cmd/tui/main.go: entry point with --server, --token, --version flags
- cmd/tui/config.go: config from ~/.config/dumpster/config.yaml or env vars
- cmd/tui/auth.go: login flow, session cookie management
- cmd/tui/api.go: HTTP client for servers, channels, messages, voice
- cmd/tui/model.go: root bubbletea model with state management
- cmd/tui/theme.go: Gruvbox dark lipgloss styles
- cmd/tui/servers.go: server bar with [D] style initials
- cmd/tui/channels.go: channel list with #text and 🔊 voice
- cmd/tui/chat.go: IRC-style message viewport with colored usernames
- cmd/tui/input.go: message input with > _ prompt
- cmd/tui/members.go: member list with ●/◐/○ status
- cmd/tui/ws.go: WebSocket client for real-time events
- cmd/tui/voice.go: voice state tracking and mute toggle
- cmd/tui/keys.go: vim-style keybindings (j/k, g/G, Tab, /, etc)
- cmd/tui/views.go: multi-pane layout rendering
- Makefile: added build-tui and run-tui targets
- go.mod/go.sum: added charmbracelet dependencies
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
// RunAuth performs interactive login and returns the session token.
|
||||
func RunAuth(api *APIClient) (string, error) {
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
|
||||
fmt.Println(TitleStyle.Render("🗑 Dumpster Chat TUI"))
|
||||
fmt.Println(HelpStyle.Render(" Log in to continue\n"))
|
||||
|
||||
fmt.Print(" Email: ")
|
||||
email, _ := reader.ReadString('\n')
|
||||
email = strings.TrimSpace(email)
|
||||
|
||||
fmt.Print(" Password: ")
|
||||
pwBytes, err := term.ReadPassword(int(syscall.Stdin))
|
||||
if err != nil {
|
||||
// Fallback to plain read
|
||||
fmt.Scanln(&email)
|
||||
return "", fmt.Errorf("read password: %w", err)
|
||||
}
|
||||
fmt.Println() // newline after password
|
||||
|
||||
password := strings.TrimSpace(string(pwBytes))
|
||||
|
||||
if email == "" || password == "" {
|
||||
return "", fmt.Errorf("email and password are required")
|
||||
}
|
||||
|
||||
lr, err := api.Login(email, password)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("login failed: %w", err)
|
||||
}
|
||||
|
||||
_ = lr // user ID available if needed
|
||||
fmt.Println(SuccessStyle.Render(" ✓ Logged in successfully"))
|
||||
|
||||
return api.SessionToken, nil
|
||||
}
|
||||
Reference in New Issue
Block a user