Skip to content

Commit 382d3fd

Browse files
committed
feat: conceal password input, display better summary
1 parent 3043c6f commit 382d3fd

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

main.go

+30-14
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ package main
22

33
import (
44
"fmt"
5-
"github.com/charmbracelet/huh"
65
"log"
76
"os"
87
"os/exec"
98
"path/filepath"
9+
"strings"
1010
"time"
11+
12+
"github.com/charmbracelet/huh"
13+
"github.com/charmbracelet/lipgloss"
1114
)
1215

1316
var (
@@ -33,7 +36,7 @@ func main() {
3336
// Input for MySQL password
3437
huh.NewInput().
3538
Title("MySQL password").
36-
Value(&password),
39+
Value(&password).EchoMode(huh.EchoModePassword),
3740

3841
// Input for MySQL db name
3942
huh.NewInput().
@@ -134,24 +137,37 @@ func main() {
134137

135138
}
136139

137-
// Display the collected information
138-
fmt.Println("Migration Information:")
139-
fmt.Printf("MySQL username: %s\n", username)
140-
fmt.Printf("MySQL password: %s\n", password)
141-
fmt.Printf("MySQL database: %s\n", db)
142-
fmt.Printf("Action: %s\n", action)
143-
fmt.Printf("Migration Type: %s\n", migrationType)
144-
if action == "migrate" {
145-
fmt.Printf("Destination Directory: %s\n", directory)
140+
titleStyle := lipgloss.NewStyle().Bold(true).Background(lipgloss.Color("#6666BB")).Padding(0, 1).Margin(1, 0)
141+
142+
valueStyle := lipgloss.NewStyle().Italic(true).Foreground(lipgloss.Color("#CCCCDD"))
143+
144+
rowStyle := lipgloss.NewStyle().PaddingLeft(1)
145+
lastRowStyle := lipgloss.NewStyle().MarginBottom(1)
146+
147+
diretoryLabel := "Destination:"
148+
if action == "upload" {
149+
diretoryLabel = "Source:"
150+
directory += strings.Split(selectedMigration, " ")[0]
146151
}
147152

153+
// Display the collected information
154+
fmt.Println(titleStyle.Render("Migration Information:"))
155+
fmt.Printf("%s %s\n", rowStyle.Render("Username:"), valueStyle.Render(username))
156+
fmt.Printf("%s %s\n", rowStyle.Render("Password:"), valueStyle.Render(strings.Repeat("*", len(password))))
157+
fmt.Printf("%s %s\n", rowStyle.Render("Database:"), valueStyle.Render(db))
158+
fmt.Printf("%s %s\n", rowStyle.Render("Action:"), valueStyle.Render(action))
159+
fmt.Printf("%s %s\n", rowStyle.Render("Migration Type:"), valueStyle.Render(migrationType))
160+
fmt.Println(lastRowStyle.Render(rowStyle.Render(diretoryLabel), valueStyle.Render(directory)))
161+
162+
fmt.Println("\n")
163+
148164
// Confirmation step before proceeding with the action
149165
err = huh.NewForm(
150166
huh.NewGroup(
151167
huh.NewConfirm().
152-
Title("Are you sure?").
153-
Affirmative("Yes!").
154-
Negative("No.").
168+
Title("Confirm migration?").
169+
Affirmative("Confirm!").
170+
Negative("Cancel").
155171
Value(&confirm),
156172
),
157173
).Run()

0 commit comments

Comments
 (0)