mirror of
https://github.com/Finesssee/ProxyPilot.git
synced 2026-11-20 12:23:26 +00:00
- Bubbletea-based TUI with 5 tabs: Status, Accounts, Rate Limits, Usage, Logs - Industrial control room aesthetic with orange/green color scheme - Double-line borders (╔═╗), active tab indicator 【】 - 3-column stat boxes on Status, 4-column on Usage - Visual gauge bar for rate limit availability - Config-optional mode allows TUI to run without config.yaml - Full-width frame with properly aligned borders
46 lines
905 B
Go
46 lines
905 B
Go
package tui
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
)
|
|
|
|
// Run starts the TUI application.
|
|
func Run(proxyURL, managementKey string) error {
|
|
if proxyURL == "" {
|
|
proxyURL = "http://127.0.0.1:8318"
|
|
}
|
|
|
|
model := NewModel(proxyURL, managementKey)
|
|
p := tea.NewProgram(model, tea.WithAltScreen())
|
|
|
|
if _, err := p.Run(); err != nil {
|
|
return fmt.Errorf("failed to run TUI: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// RunWithStdio runs the TUI with custom stdio (for embedding in other programs).
|
|
func RunWithStdio(proxyURL, managementKey string, in *os.File, out *os.File) error {
|
|
if proxyURL == "" {
|
|
proxyURL = "http://127.0.0.1:8318"
|
|
}
|
|
|
|
model := NewModel(proxyURL, managementKey)
|
|
p := tea.NewProgram(
|
|
model,
|
|
tea.WithAltScreen(),
|
|
tea.WithInput(in),
|
|
tea.WithOutput(out),
|
|
)
|
|
|
|
if _, err := p.Run(); err != nil {
|
|
return fmt.Errorf("failed to run TUI: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|