Skip to content

Commit fa879d2

Browse files
Check for updates after each command
1 parent b41d2c0 commit fa879d2

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

download.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,9 @@ func runDownloadCommand(args []string, destDir string) {
5555
if err != nil {
5656
feedback.Fatal(i18n.Tr("error downloading the image: %v", err), feedback.ErrBadArgument)
5757
}
58+
59+
err = checkForUpdates()
60+
if err != nil {
61+
feedback.Warning("\n\nfailed to check for updates: " + err.Error())
62+
}
5863
}

feedback/feedback.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import (
2222
"io"
2323
"os"
2424

25-
"github.com/sirupsen/logrus"
26-
2725
"github.com/arduino/arduino-flasher-cli/i18n"
2826
)
2927

@@ -156,12 +154,7 @@ func Print(v string) {
156154

157155
// Warning outputs a warning message.
158156
func Warning(msg string) {
159-
if format == Text {
160-
fmt.Fprintln(feedbackErr, msg)
161-
} else {
162-
bufferWarnings = append(bufferWarnings, msg)
163-
}
164-
logrus.Warning(msg)
157+
fmt.Fprintln(feedbackErr, msg)
165158
}
166159

167160
// FatalError outputs the error and exits with status exitCode.

flash.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,9 @@ func runFlashCommand(ctx context.Context, args []string, forceYes bool) {
9696
if err != nil {
9797
feedback.Fatal(i18n.Tr("error flashing the board: %v", err), feedback.ErrBadArgument)
9898
}
99+
100+
err = checkForUpdates()
101+
if err != nil {
102+
feedback.Warning("\n\nfailed to check for updates: " + err.Error())
103+
}
99104
}

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ require (
1010
github.com/jedib0t/go-pretty/v6 v6.6.8
1111
github.com/leonelquinteros/gotext v1.7.2
1212
github.com/schollz/progressbar/v3 v3.18.0
13-
github.com/sirupsen/logrus v1.9.3
1413
github.com/spf13/cobra v1.9.1
1514
github.com/stretchr/testify v1.10.0
1615
go.bug.st/cleanup v1.0.0

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ github.com/sebdah/goldie/v2 v2.7.1/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvK
142142
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
143143
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
144144
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
145-
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
146-
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
147145
github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8=
148146
github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY=
149147
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
@@ -156,7 +154,6 @@ github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
156154
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
157155
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
158156
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
159-
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
160157
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
161158
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
162159
github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
@@ -209,7 +206,6 @@ gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
209206
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
210207
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
211208
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
212-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
213209
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
214210
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
215211
mvdan.cc/sh/v3 v3.12.0 h1:ejKUR7ONP5bb+UGHGEG/k9V5+pRVIyD+LsZz7o8KHrI=

list.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ func runListCommand() {
4646
}
4747

4848
feedback.PrintResult(listResult{Latest: manifest.Latest, Releases: manifest.Releases})
49+
err = checkForUpdates()
50+
if err != nil {
51+
feedback.Warning("\n\nfailed to check for updates: " + err.Error())
52+
}
4953
}
5054

5155
type listResult struct {

main.go

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

1818
import (
1919
"context"
20-
"fmt"
2120
"log/slog"
2221
"os"
2322

@@ -60,10 +59,10 @@ func main() {
6059
Use: "version",
6160
Short: "Print the version number of Arduino Flasher CLI",
6261
Run: func(cmd *cobra.Command, args []string) {
63-
fmt.Println("Arduino Flasher CLI " + Version)
62+
feedback.Print("Arduino Flasher CLI " + Version)
6463
err := checkForUpdates()
6564
if err != nil {
66-
feedback.Warning("failed to check for updates: " + err.Error())
65+
feedback.Warning("\n\nfailed to check for updates: " + err.Error())
6766
}
6867
},
6968
})

0 commit comments

Comments
 (0)