MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / renderInitAuth

Method renderInitAuth

internal/tui/app.go:496–536  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

494}
495
496func (a App) renderInitAuth() string {
497 spinners := []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧"}
498 spinner := spinners[a.loadingFrame%len(spinners)]
499
500 var content string
501 switch a.authState {
502 case AuthStatePrompt:
503 content = lipgloss.NewStyle().Foreground(lipgloss.Color("7")).Render(
504 fmt.Sprintf("\nWelcome! CloudCent requires a free API Key.\n\nPress %s to authenticate in browser...\n(Or press %s to quit)",
505 lipgloss.NewStyle().Foreground(lipgloss.Color("3")).Bold(true).Render("Enter"),
506 lipgloss.NewStyle().Foreground(lipgloss.Color("1")).Render("Esc"),
507 ))
508 case AuthStateWaiting:
509 content = lipgloss.NewStyle().Foreground(lipgloss.Color("6")).Bold(true).Render(
510 fmt.Sprintf("\n%s Waiting for browser authorization...\n\nA browser window should have opened.\nPlease complete the verification there.\n\nPress %s to cancel %s to retry",
511 spinner,
512 lipgloss.NewStyle().Foreground(lipgloss.Color("1")).Render("Esc"),
513 lipgloss.NewStyle().Foreground(lipgloss.Color("3")).Bold(true).Render("r"),
514 ))
515 case AuthStateLoading:
516 content = lipgloss.NewStyle().Foreground(lipgloss.Color("6")).Bold(true).Render(
517 fmt.Sprintf("\n%s Loading metadata...\n\nPlease wait while we download pricing data.",
518 spinner))
519 case AuthStateError:
520 content = fmt.Sprintf("\n%s\n\n%s\n\nPress %s to retry or %s to quit",
521 lipgloss.NewStyle().Foreground(lipgloss.Color("1")).Bold(true).Render("[ERROR] Authentication Failed"),
522 lipgloss.NewStyle().Foreground(lipgloss.Color("7")).Render(a.errorMsg),
523 lipgloss.NewStyle().Foreground(lipgloss.Color("3")).Bold(true).Render("Enter"),
524 lipgloss.NewStyle().Foreground(lipgloss.Color("1")).Render("Esc"),
525 )
526 }
527
528 title := fmt.Sprintf(" CloudCent CLI v%s ", a.version)
529 box := lipgloss.NewStyle().
530 Border(lipgloss.RoundedBorder()).
531 BorderForeground(lipgloss.Color("6")).
532 Align(lipgloss.Center).
533 Width(60).
534 Render(title + content)
535 return lipgloss.Place(a.width, a.height, lipgloss.Center, lipgloss.Center, box)
536}
537
538// ── Commands (async) ──────────────────────────────────────────────────────────
539

Callers 1

ViewMethod · 0.95

Calls 1

RenderMethod · 0.45

Tested by

no test coverage detected