@@ -23,6 +23,7 @@ import (
2323 "github.com/arduino/arduino-cli/arduino/libraries/librariesindex"
2424 "github.com/arduino/arduino-cli/commands"
2525 rpc "github.com/arduino/arduino-cli/rpc/commands"
26+ "github.com/imjasonmiller/godice"
2627)
2728
2829// LibrarySearch FIXMEDOC
@@ -33,6 +34,7 @@ func LibrarySearch(ctx context.Context, req *rpc.LibrarySearchReq) (*rpc.Library
3334 }
3435
3536 res := []* rpc.SearchedLibrary {}
37+ status := rpc .LibrarySearchStatus_success
3638
3739 for _ , lib := range lm .Index .Libraries {
3840 qry := strings .ToLower (req .GetQuery ())
@@ -45,16 +47,27 @@ func LibrarySearch(ctx context.Context, req *rpc.LibrarySearchReq) (*rpc.Library
4547 }
4648 latest := GetLibraryParameters (lib .Latest )
4749
48- searchedlib := & rpc.SearchedLibrary {
50+ searchedLib := & rpc.SearchedLibrary {
4951 Name : lib .Name ,
5052 Releases : releases ,
5153 Latest : latest ,
5254 }
53- res = append (res , searchedlib )
55+ res = append (res , searchedLib )
5456 }
5557 }
5658
57- return & rpc.LibrarySearchResp {Libraries : res }, nil
59+ if len (res ) == 0 {
60+ status = rpc .LibrarySearchStatus_failed
61+ for _ , lib := range lm .Index .Libraries {
62+ if godice .CompareString (req .GetQuery (), lib .Name ) > 0.7 {
63+ res = append (res , & rpc.SearchedLibrary {
64+ Name : lib .Name ,
65+ })
66+ }
67+ }
68+ }
69+
70+ return & rpc.LibrarySearchResp {Libraries : res , Status : status }, nil
5871}
5972
6073// GetLibraryParameters FIXMEDOC
0 commit comments