File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -17,21 +17,23 @@ package main
1717
1818import (
1919 "encoding/json"
20+ "fmt"
2021 "net/http"
2122 "strings"
23+ "time"
2224
2325 semver "go.bug.st/relaxed-semver"
24-
25- "github.com/arduino/arduino-flasher-cli/updater"
2626)
2727
28+ const maxTime time.Duration = 1 * time .Second
29+
2830func checkForUpdates () (string , error ) {
2931 currentVersion , err := semver .Parse (Version )
3032 if err != nil {
3133 return "" , err
3234 }
3335
34- client := http.Client {Timeout : maxTime }
36+ client := http.Client {Timeout : maxTime }
3537 resp , err := client .Get ("https://api.github.com/repos/arduino/arduino-flasher-cli/releases/latest" )
3638 if err != nil {
3739 return "" , err
Original file line number Diff line number Diff line change @@ -65,18 +65,18 @@ func main() {
6565 Name : "Arduino Flasher CLI" ,
6666 Version : Version ,
6767 })
68-
69- latest , err := checkForUpdates (1 * time . Second )
68+
69+ latest , err := checkForUpdates ()
7070 if err != nil {
7171 feedback .Warning (color .YellowString ("Failed to check for updates: " + err .Error ()) + "\n " )
7272 }
7373 if latest != "" {
74- msg := fmt .Sprintf ("%s %s → %s\n %s" ,
74+ msg := fmt .Sprintf ("\n \n %s %s → %s\n %s" ,
7575 color .YellowString (i18n .Tr ("A new release of Arduino Flasher CLI is available:" )),
7676 color .CyanString (Version ),
7777 color .CyanString (latest ),
7878 color .YellowString ("https://www.arduino.cc/en/software/#flasher-tool" ))
79- feedback .Warning (msg + " \n " )
79+ feedback .Warning (msg )
8080 }
8181 },
8282 })
@@ -87,3 +87,17 @@ func main() {
8787 slog .Error (err .Error ())
8888 }
8989}
90+
91+ type versionResult struct {
92+ Name string `json:"name"`
93+ Version string `json:"version"`
94+ }
95+
96+ func (r versionResult ) String () string {
97+ resultMessage := fmt .Sprintf ("Arduino Flasher CLI version %s" , r .Version )
98+ return resultMessage
99+ }
100+
101+ func (r versionResult ) Data () interface {} {
102+ return r
103+ }
You can’t perform that action at this time.
0 commit comments