Skip to content

Commit 94aa4c7

Browse files
Apply review suggestion
1 parent 6f3ace8 commit 94aa4c7

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

check_for_updates.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@ package main
1717

1818
import (
1919
"encoding/json"
20-
"fmt"
2120
"net/http"
2221
"strings"
2322

24-
"github.com/fatih/color"
2523
semver "go.bug.st/relaxed-semver"
2624

27-
"github.com/arduino/arduino-flasher-cli/i18n"
2825
"github.com/arduino/arduino-flasher-cli/updater"
2926
)
3027

@@ -65,11 +62,5 @@ func checkForUpdates() (string, error) {
6562
return "", nil
6663
}
6764

68-
msg := fmt.Sprintf("\n\n%s %s → %s\n%s",
69-
color.YellowString(i18n.Tr("A new release of Arduino Flasher CLI is available:")),
70-
color.CyanString(currentVersion.String()),
71-
color.CyanString(latestVersion.String()),
72-
color.YellowString("https://www.arduino.cc/en/software/#flasher-tool"))
73-
74-
return msg, nil
65+
return latestVersion.String(), nil
7566
}

main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ package main
1717

1818
import (
1919
"context"
20+
"fmt"
2021
"log/slog"
2122
"os"
2223

24+
"github.com/fatih/color"
2325
"github.com/spf13/cobra"
2426
"go.bug.st/cleanup"
2527

@@ -60,11 +62,16 @@ func main() {
6062
Short: "Print the version number of Arduino Flasher CLI",
6163
Run: func(cmd *cobra.Command, args []string) {
6264
feedback.Print("Arduino Flasher CLI " + Version)
63-
msg, err := checkForUpdates()
65+
latest, err := checkForUpdates()
6466
if err != nil {
6567
feedback.Warning("\n\nfailed to check for updates: " + err.Error())
6668
}
67-
if msg != "" {
69+
if latest != "" {
70+
msg := fmt.Sprintf("\n\n%s %s → %s\n%s",
71+
color.YellowString(i18n.Tr("A new release of Arduino Flasher CLI is available:")),
72+
color.CyanString(Version),
73+
color.CyanString(latest),
74+
color.YellowString("https://www.arduino.cc/en/software/#flasher-tool"))
6875
feedback.Print(msg)
6976
}
7077
},

0 commit comments

Comments
 (0)