2a6b3830d5
- 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
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
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
|
|
}
|