Skip to content

Commit a2f1dc6

Browse files
committed
add comments and optimize the code a little bit
1 parent 3a93b00 commit a2f1dc6

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Diff for: commands/core/list.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ func GetPlatforms(req *rpc.PlatformListRequest) ([]*rpc.Platform, error) {
3838
for _, platform := range targetPackage.Platforms {
3939
platformRelease := packageManager.GetInstalledPlatformRelease(platform)
4040

41+
// The All flags adds to the list of installed platforms the installable platforms (from the indexes)
4142
// If both All and UpdatableOnly are set All takes precedence
4243
if req.All {
4344
installedVersion := ""
44-
if platformRelease == nil {
45+
if platformRelease == nil { // if the platform is not installed
4546
platformRelease = platform.GetLatestRelease()
4647
} else {
4748
installedVersion = platformRelease.Version.String()
4849
}
50+
// it could happen, especially with indexes not perfectly compliant with specs that a platform do not contain a valid release
4951
if platformRelease != nil {
5052
rpcPlatform := commands.PlatformReleaseToRPC(platformRelease)
5153
rpcPlatform.Installed = installedVersion
@@ -60,10 +62,9 @@ func GetPlatforms(req *rpc.PlatformListRequest) ([]*rpc.Platform, error) {
6062
return nil, &arduino.PlatformNotFoundError{Platform: platform.String(), Cause: fmt.Errorf(tr("the platform has no releases"))}
6163
}
6264

63-
if req.UpdatableOnly {
64-
if latest == platformRelease {
65-
continue
66-
}
65+
// show only the updatable platforms
66+
if req.UpdatableOnly && latest == platformRelease {
67+
continue
6768
}
6869

6970
rpcPlatform := commands.PlatformReleaseToRPC(platformRelease)

Diff for: i18n/data/en.po

+1-1
Original file line numberDiff line numberDiff line change
@@ -3297,7 +3297,7 @@ msgstr "testing local archive integrity: %s"
32973297
msgid "text section exceeds available space in board"
32983298
msgstr "text section exceeds available space in board"
32993299

3300-
#: commands/core/list.go:60
3300+
#: commands/core/list.go:62
33013301
msgid "the platform has no releases"
33023302
msgstr "the platform has no releases"
33033303

0 commit comments

Comments
 (0)