@@ -34,24 +34,23 @@ import (
34
34
semver "go.bug.st/relaxed-semver"
35
35
)
36
36
37
- var (
38
- namesOnly bool // if true outputs lib names only.
39
- )
40
-
41
37
func initSearchCommand () * cobra.Command {
38
+ var namesOnly bool // if true outputs lib names only.
42
39
searchCommand := & cobra.Command {
43
40
Use : fmt .Sprintf ("search [%s]" , tr ("LIBRARY_NAME" )),
44
41
Short : tr ("Searches for one or more libraries data." ),
45
42
Long : tr ("Search for one or more libraries data (case insensitive search)." ),
46
43
Example : " " + os .Args [0 ] + " lib search audio" ,
47
44
Args : cobra .ArbitraryArgs ,
48
- Run : runSearchCommand ,
45
+ Run : func (cmd * cobra.Command , args []string ) {
46
+ runSearchCommand (args , namesOnly )
47
+ },
49
48
}
50
49
searchCommand .Flags ().BoolVar (& namesOnly , "names" , false , tr ("Show library names only." ))
51
50
return searchCommand
52
51
}
53
52
54
- func runSearchCommand (cmd * cobra. Command , args []string ) {
53
+ func runSearchCommand (args []string , namesOnly bool ) {
55
54
inst , status := instance .Create ()
56
55
logrus .Info ("Executing `arduino-cli lib search`" )
57
56
@@ -73,7 +72,7 @@ func runSearchCommand(cmd *cobra.Command, args []string) {
73
72
74
73
searchResp , err := lib .LibrarySearch (context .Background (), & rpc.LibrarySearchRequest {
75
74
Instance : inst ,
76
- Query : ( strings .Join (args , " " ) ),
75
+ Query : strings .Join (args , " " ),
77
76
})
78
77
if err != nil {
79
78
feedback .Errorf (tr ("Error searching for Libraries: %v" ), err )
@@ -125,11 +124,6 @@ func (res result) String() string {
125
124
return tr ("No libraries matching your search." )
126
125
}
127
126
128
- // get a sorted slice of results
129
- sort .Slice (results , func (i , j int ) bool {
130
- return results [i ].Name < results [j ].Name
131
- })
132
-
133
127
var out strings.Builder
134
128
135
129
if res .results .GetStatus () == rpc .LibrarySearchStatus_LIBRARY_SEARCH_STATUS_FAILED {
0 commit comments