Skip to content

Commit e77411a

Browse files
MatteoPologrutoper1234lucarin91
authored
feat: check for tool updates when printing current version (#25)
* feat: check for tool updates when printing current version * Update licenses * Add license to new file * Update check_for_updates.go Co-authored-by: Per Tillisch <accounts@perglass.com> * Revert executable changes to .licenses files * Check for updates after each command * Apply review suggestions * Remove unused license * Check for updates only when version command is run * Apply review suggestion * Update dependency license * Update check_for_updates.go Co-authored-by: Luca Rinaldi <lucarin@protonmail.com> * Update check_for_updates.go Co-authored-by: Luca Rinaldi <lucarin@protonmail.com> * Update check_for_updates.go Co-authored-by: Luca Rinaldi <lucarin@protonmail.com> * Update main.go Co-authored-by: Luca Rinaldi <lucarin@protonmail.com> * Apply review suggestion * Update feedback/feedback.go Co-authored-by: Luca Rinaldi <lucarin@protonmail.com> * Update main.go Co-authored-by: Luca Rinaldi <lucarin@protonmail.com> * Remove duplicate code --------- Co-authored-by: Per Tillisch <accounts@perglass.com> Co-authored-by: Luca Rinaldi <lucarin@protonmail.com>
1 parent 84830ab commit e77411a

File tree

10 files changed

+294
-20
lines changed

10 files changed

+294
-20
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: github.com/fatih/color
3+
version: v1.18.0
4+
type: go
5+
summary: Package color is an ANSI color package to output colorized or SGR defined
6+
output to the standard output.
7+
homepage: https://pkg.go.dev/github.com/fatih/color
8+
license: mit
9+
licenses:
10+
- sources: LICENSE.md
11+
text: |
12+
The MIT License (MIT)
13+
14+
Copyright (c) 2013 Fatih Arslan
15+
16+
Permission is hereby granted, free of charge, to any person obtaining a copy of
17+
this software and associated documentation files (the "Software"), to deal in
18+
the Software without restriction, including without limitation the rights to
19+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
20+
the Software, and to permit persons to whom the Software is furnished to do so,
21+
subject to the following conditions:
22+
23+
The above copyright notice and this permission notice shall be included in all
24+
copies or substantial portions of the Software.
25+
26+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
28+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
29+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
30+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32+
- sources: README.md
33+
text: The MIT License (MIT) - see [`LICENSE.md`](https://github.com/fatih/color/blob/master/LICENSE.md)
34+
for more details
35+
notices: []
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
---
2-
name: github.com/sirupsen/logrus
3-
version: v1.9.3
2+
name: github.com/mattn/go-colorable
3+
version: v0.1.13
44
type: go
5-
summary: Package logrus is a structured logger for Go, completely API compatible with
6-
the standard library logger.
7-
homepage: https://pkg.go.dev/github.com/sirupsen/logrus
5+
summary:
6+
homepage: https://pkg.go.dev/github.com/mattn/go-colorable
87
license: mit
98
licenses:
109
- sources: LICENSE
1110
text: |
1211
The MIT License (MIT)
1312
14-
Copyright (c) 2014 Simon Eskildsen
13+
Copyright (c) 2016 Yasuhiro Matsumoto
1514
1615
Permission is hereby granted, free of charge, to any person obtaining a copy
1716
of this software and associated documentation files (the "Software"), to deal
@@ -20,14 +19,16 @@ licenses:
2019
copies of the Software, and to permit persons to whom the Software is
2120
furnished to do so, subject to the following conditions:
2221
23-
The above copyright notice and this permission notice shall be included in
24-
all copies or substantial portions of the Software.
22+
The above copyright notice and this permission notice shall be included in all
23+
copies or substantial portions of the Software.
2524
2625
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2726
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2827
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2928
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3029
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32-
THE SOFTWARE.
30+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31+
SOFTWARE.
32+
- sources: README.md
33+
text: MIT
3334
notices: []
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: github.com/mattn/go-isatty
3+
version: v0.0.20
4+
type: go
5+
summary: Package isatty implements interface to isatty
6+
homepage: https://pkg.go.dev/github.com/mattn/go-isatty
7+
license: mit
8+
licenses:
9+
- sources: LICENSE
10+
text: |
11+
Copyright (c) Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
12+
13+
MIT License (Expat)
14+
15+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
- sources: README.md
21+
text: MIT
22+
notices: []
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: go.bug.st/relaxed-semver
3+
version: v0.15.0
4+
type: go
5+
summary:
6+
homepage: https://pkg.go.dev/go.bug.st/relaxed-semver
7+
license: bsd-3-clause
8+
licenses:
9+
- sources: LICENSE
10+
text: |2+
11+
12+
Copyright (c) 2018-2025, Cristian Maglie.
13+
All rights reserved.
14+
15+
Redistribution and use in source and binary forms, with or without
16+
modification, are permitted provided that the following conditions
17+
are met:
18+
19+
1. Redistributions of source code must retain the above copyright
20+
notice, this list of conditions and the following disclaimer.
21+
22+
2. Redistributions in binary form must reproduce the above copyright
23+
notice, this list of conditions and the following disclaimer in
24+
the documentation and/or other materials provided with the
25+
distribution.
26+
27+
3. Neither the name of the copyright holder nor the names of its
28+
contributors may be used to endorse or promote products derived
29+
from this software without specific prior written permission.
30+
31+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
34+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
35+
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
36+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
37+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
39+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
41+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42+
POSSIBILITY OF SUCH DAMAGE.
43+
44+
notices: []
45+
...
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
name: gopkg.in/yaml.v3
3+
version: v3.0.1
4+
type: go
5+
summary: Package yaml implements YAML support for the Go language.
6+
homepage: https://pkg.go.dev/gopkg.in/yaml.v3
7+
license: apache-2.0
8+
licenses:
9+
- sources: LICENSE
10+
text: |2
11+
12+
This project is covered by two different licenses: MIT and Apache.
13+
14+
#### MIT License ####
15+
16+
The following files were ported to Go from C files of libyaml, and thus
17+
are still covered by their original MIT license, with the additional
18+
copyright staring in 2011 when the project was ported over:
19+
20+
apic.go emitterc.go parserc.go readerc.go scannerc.go
21+
writerc.go yamlh.go yamlprivateh.go
22+
23+
Copyright (c) 2006-2010 Kirill Simonov
24+
Copyright (c) 2006-2011 Kirill Simonov
25+
26+
Permission is hereby granted, free of charge, to any person obtaining a copy of
27+
this software and associated documentation files (the "Software"), to deal in
28+
the Software without restriction, including without limitation the rights to
29+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
30+
of the Software, and to permit persons to whom the Software is furnished to do
31+
so, subject to the following conditions:
32+
33+
The above copyright notice and this permission notice shall be included in all
34+
copies or substantial portions of the Software.
35+
36+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
39+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
41+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
42+
SOFTWARE.
43+
44+
### Apache License ###
45+
46+
All the remaining project files are covered by the Apache license:
47+
48+
Copyright (c) 2011-2019 Canonical Ltd
49+
50+
Licensed under the Apache License, Version 2.0 (the "License");
51+
you may not use this file except in compliance with the License.
52+
You may obtain a copy of the License at
53+
54+
http://www.apache.org/licenses/LICENSE-2.0
55+
56+
Unless required by applicable law or agreed to in writing, software
57+
distributed under the License is distributed on an "AS IS" BASIS,
58+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
59+
See the License for the specific language governing permissions and
60+
limitations under the License.
61+
- sources: README.md
62+
text: |-
63+
The yaml package is licensed under the MIT and Apache License 2.0 licenses.
64+
Please see the LICENSE file for details.
65+
notices:
66+
- sources: NOTICE
67+
text: |-
68+
Copyright 2011-2016 Canonical Ltd.
69+
70+
Licensed under the Apache License, Version 2.0 (the "License");
71+
you may not use this file except in compliance with the License.
72+
You may obtain a copy of the License at
73+
74+
http://www.apache.org/licenses/LICENSE-2.0
75+
76+
Unless required by applicable law or agreed to in writing, software
77+
distributed under the License is distributed on an "AS IS" BASIS,
78+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
79+
See the License for the specific language governing permissions and
80+
limitations under the License.

check_for_updates.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// This file is part of arduino-flasher-cli.
2+
//
3+
// Copyright 2025 ARDUINO SA (http://www.arduino.cc/)
4+
//
5+
// This software is released under the GNU General Public License version 3,
6+
// which covers the main part of arduino-flasher-cli.
7+
// The terms of this license can be found at:
8+
// https://www.gnu.org/licenses/gpl-3.0.en.html
9+
//
10+
// You can be released from the requirements of the above licenses by purchasing
11+
// a commercial license. Buying such a license is mandatory if you want to
12+
// modify or otherwise use the software for commercial activities involving the
13+
// Arduino software without disclosing the source code of your own applications.
14+
// To purchase a commercial license, send an email to license@arduino.cc.
15+
16+
package main
17+
18+
import (
19+
"encoding/json"
20+
"fmt"
21+
"net/http"
22+
"strings"
23+
"time"
24+
25+
semver "go.bug.st/relaxed-semver"
26+
)
27+
28+
const maxTime time.Duration = 1 * time.Second
29+
30+
func checkForUpdates() (string, error) {
31+
currentVersion, err := semver.Parse(Version)
32+
if err != nil {
33+
return "", err
34+
}
35+
36+
client := http.Client{Timeout: maxTime}
37+
resp, err := client.Get("https://api.github.com/repos/arduino/arduino-flasher-cli/releases/latest")
38+
if err != nil {
39+
return "", err
40+
}
41+
defer resp.Body.Close()
42+
if resp.StatusCode != http.StatusOK {
43+
return "", fmt.Errorf("failed to fetch latest release: status code %d", resp.StatusCode)
44+
}
45+
var release struct {
46+
TagName string `json:"tag_name"`
47+
}
48+
err = json.NewDecoder(resp.Body).Decode(&release)
49+
if err != nil {
50+
return "", err
51+
}
52+
53+
release.TagName = strings.TrimPrefix(release.TagName, "v")
54+
latestVersion, err := semver.Parse(release.TagName)
55+
if err != nil {
56+
return "", err
57+
}
58+
59+
// Do nothing if the Arduino Flasher CLI is up to date
60+
if currentVersion.GreaterThanOrEqual(latestVersion) {
61+
return "", nil
62+
}
63+
64+
return latestVersion.String(), nil
65+
}

feedback/feedback.go

Lines changed: 0 additions & 3 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

@@ -161,7 +159,6 @@ func Warning(msg string) {
161159
} else {
162160
bufferWarnings = append(bufferWarnings, msg)
163161
}
164-
logrus.Warning(msg)
165162
}
166163

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

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ require (
66
github.com/arduino/go-paths-helper v1.14.0
77
github.com/arduino/go-windows-runas v1.0.1
88
github.com/codeclysm/extract/v4 v4.0.0
9+
github.com/fatih/color v1.18.0
910
github.com/jedib0t/go-pretty/v6 v6.6.8
1011
github.com/leonelquinteros/gotext v1.7.2
1112
github.com/schollz/progressbar/v3 v3.18.0
1213
github.com/shirou/gopsutil/v4 v4.25.10
13-
github.com/sirupsen/logrus v1.9.3
1414
github.com/spf13/cobra v1.9.1
1515
github.com/stretchr/testify v1.11.1
1616
go.bug.st/cleanup v1.0.0
1717
go.bug.st/f v0.4.0
18+
go.bug.st/relaxed-semver v0.15.0
1819
)
1920

2021
require (
@@ -33,7 +34,6 @@ require (
3334
github.com/ebitengine/purego v0.9.0 // indirect
3435
github.com/elliotchance/orderedmap/v3 v3.1.0 // indirect
3536
github.com/emirpasic/gods v1.18.1 // indirect
36-
github.com/fatih/color v1.18.0 // indirect
3737
github.com/fsnotify/fsnotify v1.9.0 // indirect
3838
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
3939
github.com/go-git/go-billy/v5 v5.6.2 // indirect

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG
151151
github.com/shirou/gopsutil/v4 v4.25.10 h1:at8lk/5T1OgtuCp+AwrDofFRjnvosn0nkN2OLQ6g8tA=
152152
github.com/shirou/gopsutil/v4 v4.25.10/go.mod h1:+kSwyC8DRUD9XXEHCAFjK+0nuArFJM0lva+StQAcskM=
153153
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
154-
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
155-
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
156154
github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8=
157155
github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY=
158156
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
@@ -165,7 +163,6 @@ github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
165163
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
166164
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
167165
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
168-
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
169166
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
170167
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
171168
github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
@@ -182,6 +179,8 @@ go.bug.st/cleanup v1.0.0 h1:XVj1HZxkBXeq3gMT7ijWUpHyIC1j8XAoNSyQ06CskgA=
182179
go.bug.st/cleanup v1.0.0/go.mod h1:EqVmTg2IBk4znLbPD28xne3abjsJftMdqqJEjhn70bk=
183180
go.bug.st/f v0.4.0 h1:Vstqb950nMA+PhAlRxUw8QL1ntHy/gXHNyyzjkQLJ10=
184181
go.bug.st/f v0.4.0/go.mod h1:bMo23205ll7UW63KwO1ut5RdlJ9JK8RyEEr88CmOF5Y=
182+
go.bug.st/relaxed-semver v0.15.0 h1:w37+SYQPxF53RQO7QZZuPIMaPouOifdaP0B1ktst2nA=
183+
go.bug.st/relaxed-semver v0.15.0/go.mod h1:bwHiCtYuD2m716tBk2OnOBjelsbXw9el5EIuyxT/ksU=
185184
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
186185
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
187186
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
@@ -221,7 +220,6 @@ gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
221220
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
222221
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
223222
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
224-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
225223
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
226224
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
227225
mvdan.cc/sh/v3 v3.12.0 h1:ejKUR7ONP5bb+UGHGEG/k9V5+pRVIyD+LsZz7o8KHrI=

0 commit comments

Comments
 (0)