/
secretsSetupPrompt.go
97 lines (76 loc) · 2.77 KB
/
secretsSetupPrompt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package config
import (
"fmt"
"github.com/charmbracelet/lipgloss"
)
func SecretsSetupPrompt() {
// Header box style
headerBoxStyle := lipgloss.NewStyle().
Foreground(lipgloss.Color("black")).
Background(lipgloss.Color("#51e2f5")).
Bold(true).
PaddingTop(1).
PaddingBottom(1).
PaddingLeft(3).
PaddingRight(3).
Align(lipgloss.Center).
Border(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.Color("#51e2f5"))
// Apply a larger font size effect
headerContent := "GO Spotify CLI Setup Guide"
header := headerBoxStyle.Render(headerContent)
// Body style
bodyStyle := lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#51e2f5")).
PaddingLeft(4).
PaddingRight(4).
PaddingTop(1).
PaddingBottom(1)
// URL style
urlStyle := lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#007AFF")) // Blue color for URLs
// URLs
url1 := urlStyle.Render(fmt.Sprintf("%s%s", ServerUrl, UserModifyPlaybackStateRouteCallback))
url2 := urlStyle.Render(fmt.Sprintf("%s%s", ServerUrl, UserReadPlaybackStateRouteCallback))
url3 := urlStyle.Render(fmt.Sprintf("%s%s", ServerUrl, UserLibraryReadRouteCallback))
// Prepare body and footer content with highlighted URLs
body := bodyStyle.Render(fmt.Sprintf(`To get started, you'll need a 'Client ID' and 'Client Secret' from Spotify's Developer Dashboard:
1. 🔗 Navigate to: https://developer.spotify.com/dashboard/applications
2. 🚪 Sign in or create a Spotify account.
3. ➕ Click on 'Create An App'.
4. 📜 Fill in the app details.
5. ❗ In the app settings, set your Redirect URIs. Ensure your CLI tool's callback URL is added.
6. 🌐 In order to authenticate with Spotify, in Redirect URIs field please enter following URLs in the app you created:
📎 %s
%s
%s
7. 🛍 Once App created, you'll find the 'Client ID' and 'Client Secret' on the app details page.`, url1, url2, url3))
// Footer style
footerStyle := lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#FF0000")).
PaddingTop(1).
PaddingBottom(1)
footer := footerStyle.Render("🚫 Remember: Keep your 'Client Secret and Client Id' confidential. Never share it!")
// Determine the widest element for the overall box
maxWidth := lipgloss.Width(header)
bodyWidth := lipgloss.Width(body)
if bodyWidth > maxWidth {
maxWidth = bodyWidth
}
footerWidth := lipgloss.Width(footer)
if footerWidth > maxWidth {
maxWidth = footerWidth
}
// Box style for the entire content
box := lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.Color("#51e2f5")).
Width(maxWidth + 2). // Adding some extra space for padding
MarginTop(1).
MarginBottom(1)
// Render the box with centered content
fmt.Println(box.Render(lipgloss.JoinVertical(lipgloss.Center, header, body, footer)))
}