Skip to content

Commit 237a355

Browse files
committed
add comments and optimize the code a little bit
1 parent da29b42 commit 237a355

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

commands/core/list.go

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

40+
// The All flags adds to the list of installed platforms the installable platforms (from the indexes)
4041
// If both All and UpdatableOnly are set All takes precedence
4142
if req.All {
4243
installedVersion := ""
43-
if platformRelease == nil {
44+
if platformRelease == nil { // if the platform is not installed
4445
platformRelease = platform.GetLatestRelease()
4546
} else {
4647
installedVersion = platformRelease.Version.String()
4748
}
49+
// it could happen, especially with indexes not perfectly compliant with specs that a platform do not contain a valid release
4850
if platformRelease != nil {
4951
rpcPlatform := commands.PlatformReleaseToRPC(platformRelease)
5052
rpcPlatform.Installed = installedVersion
@@ -59,10 +61,9 @@ func GetPlatforms(req *rpc.PlatformListRequest) ([]*rpc.Platform, error) {
5961
return nil, &commands.PlatformNotFound{Platform: platform.String(), Cause: errors.New(tr("the platform has no releases"))}
6062
}
6163

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

6869
rpcPlatform := commands.PlatformReleaseToRPC(platformRelease)

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:59
3300+
#: commands/core/list.go:61
33013301
msgid "the platform has no releases"
33023302
msgstr "the platform has no releases"
33033303

0 commit comments

Comments
 (0)