@@ -2,12 +2,15 @@ package main
2
2
3
3
import (
4
4
"fmt"
5
- "github.com/charmbracelet/huh"
6
5
"log"
7
6
"os"
8
7
"os/exec"
9
8
"path/filepath"
9
+ "strings"
10
10
"time"
11
+
12
+ "github.com/charmbracelet/huh"
13
+ "github.com/charmbracelet/lipgloss"
11
14
)
12
15
13
16
var (
@@ -33,7 +36,7 @@ func main() {
33
36
// Input for MySQL password
34
37
huh .NewInput ().
35
38
Title ("MySQL password" ).
36
- Value (& password ),
39
+ Value (& password ). EchoMode ( huh . EchoModePassword ) ,
37
40
38
41
// Input for MySQL db name
39
42
huh .NewInput ().
@@ -134,24 +137,37 @@ func main() {
134
137
135
138
}
136
139
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 ]
146
151
}
147
152
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
+
148
164
// Confirmation step before proceeding with the action
149
165
err = huh .NewForm (
150
166
huh .NewGroup (
151
167
huh .NewConfirm ().
152
- Title ("Are you sure ?" ).
153
- Affirmative ("Yes !" ).
154
- Negative ("No. " ).
168
+ Title ("Confirm migration ?" ).
169
+ Affirmative ("Confirm !" ).
170
+ Negative ("Cancel " ).
155
171
Value (& confirm ),
156
172
),
157
173
).Run ()
0 commit comments