@@ -66,6 +66,7 @@ func ParseReference(arg string) (*Reference, error) {
66
66
if arg == "" {
67
67
return nil , fmt .Errorf (tr ("invalid empty core argument" ))
68
68
}
69
+
69
70
toks := strings .SplitN (arg , "@" , 2 )
70
71
if toks [0 ] == "" {
71
72
return nil , fmt .Errorf (tr ("invalid empty core reference '%s'" ), arg )
@@ -85,23 +86,27 @@ func ParseReference(arg string) (*Reference, error) {
85
86
if toks [0 ] == "" {
86
87
return nil , fmt .Errorf (tr ("invalid empty core name '%s'" ), arg )
87
88
}
88
- ret .PackageName = toks [0 ]
89
89
if toks [1 ] == "" {
90
90
return nil , fmt .Errorf (tr ("invalid empty core architecture '%s'" ), arg )
91
91
}
92
+ ret .PackageName = toks [0 ]
92
93
ret .Architecture = toks [1 ]
93
94
94
95
// Now that we have the required informations in `ret` we can
95
96
// try to use core.PlatformList to optimize what the user typed
96
97
// (by replacing the PackageName and Architecture in ret with the content of core.GetPlatform())
97
- platforms , _ := core .PlatformList (& rpc.PlatformListRequest {
98
- Instance : instance .CreateAndInit (),
99
- UpdatableOnly : false ,
100
- All : true , // this is true because we want also the installable platforms
98
+ platforms , _ := core .PlatformSearch (& rpc.PlatformSearchRequest {
99
+ Instance : instance .CreateAndInit (),
100
+ AllVersions : false ,
101
101
})
102
102
foundPlatforms := []string {}
103
- for _ , platform := range platforms .InstalledPlatforms {
104
- platformID := platform .GetId ()
103
+ for _ , platform := range platforms .GetSearchOutput () {
104
+ installedRelease := platform .GetInstalledRelease ()
105
+ if installedRelease == nil {
106
+ continue
107
+ }
108
+
109
+ platformID := platform .GetMetadata ().GetId ()
105
110
platformUser := ret .PackageName + ":" + ret .Architecture
106
111
// At first we check if the platform the user is searching for matches an available one,
107
112
// this way we do not need to adapt the casing and we can return it directly
@@ -110,7 +115,6 @@ func ParseReference(arg string) (*Reference, error) {
110
115
}
111
116
if strings .EqualFold (platformUser , platformID ) {
112
117
logrus .Infof ("Found possible match for reference %s -> %s" , platformUser , platformID )
113
- toks = strings .Split (platformID , ":" )
114
118
foundPlatforms = append (foundPlatforms , platformID )
115
119
}
116
120
}
@@ -122,6 +126,7 @@ func ParseReference(arg string) (*Reference, error) {
122
126
if len (foundPlatforms ) > 1 {
123
127
return nil , & arduino.MultiplePlatformsError {Platforms : foundPlatforms , UserPlatform : arg }
124
128
}
129
+ toks = strings .Split (foundPlatforms [0 ], ":" )
125
130
ret .PackageName = toks [0 ]
126
131
ret .Architecture = toks [1 ]
127
132
return ret , nil
0 commit comments