Skip to content

Commit 24540f3

Browse files
committed
feat: polish version and update UX
- Style 'fontget version' as 'FontGet <version>' using main info color - Show current/available versions clearly in update command - Trim extra blank lines in release notes display - Add spinner while updating FontGet and simplify success messaging
1 parent 169b7ad commit 24540f3

File tree

2 files changed

+51
-13
lines changed

2 files changed

+51
-13
lines changed

cmd/update.go

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func handleCheckOnly() error {
115115
notes := formatReleaseNotes(result.Release.ReleaseNotes)
116116
if notes != "" {
117117
fmt.Printf("\n%s\n", ui.PageSubtitle.Render("Release Notes:"))
118+
// Avoid trailing blank line after notes
118119
fmt.Printf("%s\n", ui.FeedbackText.Render(notes))
119120
}
120121
}
@@ -161,14 +162,15 @@ func handleUpdateFlow(autoYes bool) error {
161162
}
162163

163164
// Show update information
164-
fmt.Printf("\n%s\n", ui.PageTitle.Render("Update Available"))
165-
fmt.Printf("%s\n", ui.FeedbackInfo.Render(fmt.Sprintf("FontGet v%s is available (you have v%s).", result.Latest, result.Current)))
165+
fmt.Printf("%s\n", ui.FeedbackInfo.Render(fmt.Sprintf("Current Installed Version: %s", result.Current)))
166+
fmt.Printf("%s\n", ui.FeedbackInfo.Render(fmt.Sprintf("Version Available: %s", result.Latest)))
166167

167168
// Show release notes if available
168169
if result.Release != nil && result.Release.ReleaseNotes != "" {
169170
notes := formatReleaseNotes(result.Release.ReleaseNotes)
170171
if notes != "" {
171172
fmt.Printf("\n%s\n", ui.PageSubtitle.Render("Release Notes:"))
173+
// Avoid trailing blank line after notes
172174
fmt.Printf("%s\n", ui.FeedbackText.Render(notes))
173175
}
174176
}
@@ -180,7 +182,7 @@ func handleUpdateFlow(autoYes bool) error {
180182

181183
confirmed, err := components.RunConfirm(
182184
"Update FontGet",
183-
fmt.Sprintf("Do you want to update FontGet from v%s to v%s?", result.Current, result.Latest),
185+
fmt.Sprintf("Do you want to update FontGet from %s to %s?", result.Current, result.Latest),
184186
)
185187
if err != nil {
186188
if logger != nil {
@@ -224,13 +226,14 @@ func handleUpdateToVersion(targetVersion string, autoYes bool) error {
224226

225227
// Check if target version is different from current
226228
if targetVersion == currentVersion {
227-
fmt.Printf("%s\n", ui.FeedbackInfo.Render(fmt.Sprintf("FontGet is already at version v%s", currentVersion)))
229+
fmt.Printf("%s\n", ui.FeedbackInfo.Render(fmt.Sprintf("FontGet is already at version %s", currentVersion)))
228230
return nil
229231
}
230232

231233
// Show update information
232234
fmt.Printf("\n%s\n", ui.PageTitle.Render("Update to Specific Version"))
233-
fmt.Printf("%s\n", ui.FeedbackInfo.Render(fmt.Sprintf("Updating FontGet from v%s to v%s", currentVersion, targetVersion)))
235+
fmt.Printf("%s\n", ui.FeedbackInfo.Render(fmt.Sprintf("Current Installed Version: %s", currentVersion)))
236+
fmt.Printf("%s\n", ui.FeedbackInfo.Render(fmt.Sprintf("Version Available: %s", targetVersion)))
234237

235238
// Prompt for confirmation unless auto-yes
236239
if !autoYes {
@@ -239,7 +242,7 @@ func handleUpdateToVersion(targetVersion string, autoYes bool) error {
239242

240243
confirmed, err := components.RunConfirm(
241244
"Update FontGet",
242-
fmt.Sprintf("Do you want to update FontGet from v%s to v%s?", currentVersion, targetVersion),
245+
fmt.Sprintf("Do you want to update FontGet from %s to %s?", currentVersion, targetVersion),
243246
)
244247
if err != nil {
245248
if logger != nil {
@@ -269,7 +272,13 @@ func handleUpdateToVersion(targetVersion string, autoYes bool) error {
269272
output.GetVerbose().Info("Starting update to version %s", targetVersion)
270273
output.GetDebug().State("Calling update.UpdateToVersion(%s)", targetVersion)
271274

272-
err := update.UpdateToVersion(targetVersion)
275+
err := ui.RunSpinner(
276+
fmt.Sprintf("Updating FontGet from %s to %s...", currentVersion, targetVersion),
277+
fmt.Sprintf("Successfully updated to FontGet %s", targetVersion),
278+
func() error {
279+
return update.UpdateToVersion(targetVersion)
280+
},
281+
)
273282
if err != nil {
274283
if logger != nil {
275284
logger.Error("Failed to update to version %s: %v", targetVersion, err)
@@ -286,8 +295,7 @@ func handleUpdateToVersion(targetVersion string, autoYes bool) error {
286295

287296
output.GetVerbose().Info("Update complete")
288297
output.GetDebug().State("Update successful")
289-
fmt.Printf("%s\n", ui.FeedbackSuccess.Render(fmt.Sprintf("FontGet updated successfully from v%s to v%s", currentVersion, targetVersion)))
290-
fmt.Printf("%s\n", ui.FeedbackText.Render("Restart FontGet to use the new version."))
298+
fmt.Printf("%s\n", ui.FeedbackSuccess.Render(fmt.Sprintf("Successfully updated to FontGet %s", targetVersion)))
291299

292300
return nil
293301
}
@@ -298,7 +306,14 @@ func performUpdate(currentVersion, latestVersion string) error {
298306
output.GetVerbose().Info("Starting update to version %s", latestVersion)
299307
output.GetDebug().State("Calling update.UpdateToLatest()")
300308

301-
err := update.UpdateToLatest()
309+
// Show spinner while performing the update
310+
err := ui.RunSpinner(
311+
fmt.Sprintf("Updating FontGet from %s to %s...", currentVersion, latestVersion),
312+
fmt.Sprintf("Successfully updated to FontGet %s", latestVersion),
313+
func() error {
314+
return update.UpdateToLatest()
315+
},
316+
)
302317
if err != nil {
303318
if logger != nil {
304319
logger.Error("Failed to update: %v", err)
@@ -315,8 +330,7 @@ func performUpdate(currentVersion, latestVersion string) error {
315330

316331
output.GetVerbose().Info("Update complete")
317332
output.GetDebug().State("Update successful")
318-
fmt.Printf("%s\n", ui.FeedbackSuccess.Render(fmt.Sprintf("FontGet updated successfully from v%s to v%s", currentVersion, latestVersion)))
319-
fmt.Printf("%s\n", ui.FeedbackText.Render("Restart FontGet to use the new version."))
333+
fmt.Printf("%s\n", ui.FeedbackSuccess.Render(fmt.Sprintf("Successfully updated to FontGet %s", latestVersion)))
320334

321335
return nil
322336
}
@@ -328,6 +342,12 @@ func formatReleaseNotes(notes string) string {
328342
}
329343

330344
lines := strings.Split(notes, "\n")
345+
346+
// Trim trailing empty lines to avoid extra blank space at the end
347+
for len(lines) > 0 && strings.TrimSpace(lines[len(lines)-1]) == "" {
348+
lines = lines[:len(lines)-1]
349+
}
350+
331351
maxLines := 10
332352
if len(lines) > maxLines {
333353
lines = lines[:maxLines]

cmd/version.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package cmd
22

33
import (
44
"fmt"
5+
6+
"fontget/internal/ui"
57
"fontget/internal/version"
68

79
"github.com/spf13/cobra"
@@ -15,7 +17,23 @@ var versionCmd = &cobra.Command{
1517
Example: ` fontget version`,
1618
Args: cobra.NoArgs,
1719
Run: func(cmd *cobra.Command, args []string) {
18-
fmt.Println(version.GetFullVersion())
20+
// Primary version line - styled with main info color
21+
versionLine := ui.RenderInfo("FontGet " + version.GetVersion())
22+
fmt.Println(versionLine)
23+
24+
// When debug is enabled, show detailed build information
25+
if IsDebug() {
26+
commit := version.GitCommit
27+
if len(commit) > 7 {
28+
commit = commit[:7]
29+
}
30+
31+
fmt.Printf("Commit: %s\n", commit)
32+
33+
if version.BuildDate != "unknown" {
34+
fmt.Printf("Build: %s\n", version.BuildDate)
35+
}
36+
}
1937
},
2038
}
2139

0 commit comments

Comments
 (0)