@@ -23,6 +23,7 @@ import (
23
23
"github.com/arduino/arduino-cli/arduino/libraries/librariesindex"
24
24
"github.com/arduino/arduino-cli/commands"
25
25
rpc "github.com/arduino/arduino-cli/rpc/commands"
26
+ "github.com/imjasonmiller/godice"
26
27
semver "go.bug.st/relaxed-semver"
27
28
)
28
29
@@ -34,6 +35,7 @@ func LibrarySearch(ctx context.Context, req *rpc.LibrarySearchReq) (*rpc.Library
34
35
}
35
36
36
37
res := []* rpc.SearchedLibrary {}
38
+ status := rpc .LibrarySearchStatus_success
37
39
38
40
for _ , lib := range lm .Index .Libraries {
39
41
qry := strings .ToLower (req .GetQuery ())
@@ -46,16 +48,27 @@ func LibrarySearch(ctx context.Context, req *rpc.LibrarySearchReq) (*rpc.Library
46
48
}
47
49
latest := GetLibraryParameters (lib .Latest )
48
50
49
- searchedlib := & rpc.SearchedLibrary {
51
+ searchedLib := & rpc.SearchedLibrary {
50
52
Name : lib .Name ,
51
53
Releases : releases ,
52
54
Latest : latest ,
53
55
}
54
- res = append (res , searchedlib )
56
+ res = append (res , searchedLib )
55
57
}
56
58
}
57
59
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
59
72
}
60
73
61
74
// GetLibraryParameters FIXMEDOC
0 commit comments