@@ -34,24 +34,23 @@ import (
3434 semver "go.bug.st/relaxed-semver"
3535)
3636
37- var (
38- namesOnly bool // if true outputs lib names only.
39- )
40-
4137func initSearchCommand () * cobra.Command {
38+ var namesOnly bool // if true outputs lib names only.
4239 searchCommand := & cobra.Command {
4340 Use : fmt .Sprintf ("search [%s]" , tr ("LIBRARY_NAME" )),
4441 Short : tr ("Searches for one or more libraries data." ),
4542 Long : tr ("Search for one or more libraries data (case insensitive search)." ),
4643 Example : " " + os .Args [0 ] + " lib search audio" ,
4744 Args : cobra .ArbitraryArgs ,
48- Run : runSearchCommand ,
45+ Run : func (cmd * cobra.Command , args []string ) {
46+ runSearchCommand (args , namesOnly )
47+ },
4948 }
5049 searchCommand .Flags ().BoolVar (& namesOnly , "names" , false , tr ("Show library names only." ))
5150 return searchCommand
5251}
5352
54- func runSearchCommand (cmd * cobra. Command , args []string ) {
53+ func runSearchCommand (args []string , namesOnly bool ) {
5554 inst , status := instance .Create ()
5655 logrus .Info ("Executing `arduino-cli lib search`" )
5756
@@ -73,7 +72,7 @@ func runSearchCommand(cmd *cobra.Command, args []string) {
7372
7473 searchResp , err := lib .LibrarySearch (context .Background (), & rpc.LibrarySearchRequest {
7574 Instance : inst ,
76- Query : ( strings .Join (args , " " ) ),
75+ Query : strings .Join (args , " " ),
7776 })
7877 if err != nil {
7978 feedback .Errorf (tr ("Error searching for Libraries: %v" ), err )
@@ -125,11 +124,6 @@ func (res result) String() string {
125124 return tr ("No libraries matching your search." )
126125 }
127126
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-
133127 var out strings.Builder
134128
135129 if res .results .GetStatus () == rpc .LibrarySearchStatus_LIBRARY_SEARCH_STATUS_FAILED {
0 commit comments