@@ -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 semver "go.bug.st/relaxed-semver"
2728)
2829
@@ -34,6 +35,7 @@ func LibrarySearch(ctx context.Context, req *rpc.LibrarySearchReq) (*rpc.Library
3435 }
3536
3637 res := []* rpc.SearchedLibrary {}
38+ status := rpc .LibrarySearchStatus_success
3739
3840 for _ , lib := range lm .Index .Libraries {
3941 qry := strings .ToLower (req .GetQuery ())
@@ -46,16 +48,27 @@ func LibrarySearch(ctx context.Context, req *rpc.LibrarySearchReq) (*rpc.Library
4648 }
4749 latest := GetLibraryParameters (lib .Latest )
4850
49- searchedlib := & rpc.SearchedLibrary {
51+ searchedLib := & rpc.SearchedLibrary {
5052 Name : lib .Name ,
5153 Releases : releases ,
5254 Latest : latest ,
5355 }
54- res = append (res , searchedlib )
56+ res = append (res , searchedLib )
5557 }
5658 }
5759
58- return & rpc.LibrarySearchResp {Libraries : res }, nil
60+ if len (res ) == 0 {
61+ status = rpc .LibrarySearchStatus_failed
62+ for _ , lib := range lm .Index .Libraries {
63+ if godice .CompareString (req .GetQuery (), lib .Name ) > 0.7 {
64+ res = append (res , & rpc.SearchedLibrary {
65+ Name : lib .Name ,
66+ })
67+ }
68+ }
69+ }
70+
71+ return & rpc.LibrarySearchResp {Libraries : res , Status : status }, nil
5972}
6073
6174// GetLibraryParameters FIXMEDOC
0 commit comments