File tree Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ package arguments
18
18
import (
19
19
"fmt"
20
20
"strings"
21
+
22
+ "github.com/arduino/arduino-cli/cli/instance"
23
+ "github.com/arduino/arduino-cli/commands/core"
24
+ rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
21
25
)
22
26
23
27
// Reference represents a reference item (core or library) passed to the CLI
@@ -80,5 +84,20 @@ func ParseReference(arg string) (*Reference, error) {
80
84
}
81
85
ret .Architecture = toks [1 ]
82
86
87
+ // We try to optimize the search and help the user
88
+ platforms , _ := core .GetPlatforms (& rpc.PlatformListRequest {
89
+ Instance : instance .CreateAndInit (),
90
+ UpdatableOnly : false ,
91
+ All : true ,
92
+ })
93
+ for _ , platform := range platforms {
94
+ if strings .EqualFold (platform .GetId (), ret .PackageName + ":" + ret .Architecture ) {
95
+ toks = strings .Split (platform .GetId (), ":" )
96
+ ret .PackageName = toks [0 ]
97
+ ret .Architecture = toks [1 ]
98
+ break // is it ok to stop at the first result?
99
+ }
100
+ }
101
+
83
102
return ret , nil
84
103
}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
19
19
"testing"
20
20
21
21
"github.com/arduino/arduino-cli/cli/arguments"
22
+ "github.com/arduino/arduino-cli/configuration"
22
23
"github.com/stretchr/testify/assert"
23
24
"github.com/stretchr/testify/require"
24
25
)
@@ -45,6 +46,10 @@ var badCores = []struct {
45
46
{"" , nil },
46
47
}
47
48
49
+ func init () {
50
+ configuration .Settings = configuration .Init ("" )
51
+ }
52
+
48
53
func TestArgsStringify (t * testing.T ) {
49
54
for _ , core := range goodCores {
50
55
require .Equal (t , core .in , core .expected .String ())
Original file line number Diff line number Diff line change @@ -4,15 +4,16 @@ Here you can find a list of migration guides to handle breaking changes between
4
4
5
5
## Unreleased
6
6
7
- ### ` ParseReferences() function change in ` arduino-cli` package
7
+ ### ` ParseReferences() function change in ` arduino-cli` package
8
8
9
9
The ` parseArch ` parameter was removed since it was unused and was always true. This means that the architecture gets
10
10
always parsed by the function.
11
11
12
- ### ` ParseReference() function change in ` arduino-cli` package
12
+ ### ` ParseReference() function change in ` arduino-cli` package
13
13
14
14
The ` parseArch ` parameter was removed since it was unused and was always true. This means that the architecture gets
15
- always parsed by the function.
15
+ always parsed by the function. Furthermore the function now should also correctly interpret ` packager:arch ` spelled with
16
+ the wrong casing.
16
17
17
18
## 0.20.0
18
19
You can’t perform that action at this time.
0 commit comments