Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c6afede

Browse filesBrowse files
Use the same property name for the query term in search requests (#2214)
* Deprecate `query` in favor of `search_args` * Give priority to `search_args` if possible
1 parent 5725c02 commit c6afede
Copy full SHA for c6afede

File tree

Expand file treeCollapse file tree

8 files changed

+271
-252
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+271
-252
lines changed

‎client_example/main.go

Copy file name to clipboardExpand all lines: client_example/main.go
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,8 @@ func callLibUpgradeAll(client rpc.ArduinoCoreServiceClient, instance *rpc.Instan
881881
func callLibSearch(client rpc.ArduinoCoreServiceClient, instance *rpc.Instance) {
882882
libSearchResp, err := client.LibrarySearch(context.Background(),
883883
&rpc.LibrarySearchRequest{
884-
Instance: instance,
885-
Query: "audio",
884+
Instance: instance,
885+
SearchArgs: "audio",
886886
})
887887

888888
if err != nil {

‎commands/lib/search.go

Copy file name to clipboardExpand all lines: commands/lib/search.go
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ func LibrarySearch(ctx context.Context, req *rpc.LibrarySearchRequest) (*rpc.Lib
4040

4141
func searchLibrary(req *rpc.LibrarySearchRequest, lm *librariesmanager.LibrariesManager) *rpc.LibrarySearchResponse {
4242
res := []*rpc.SearchedLibrary{}
43-
query := req.GetQuery()
43+
query := req.GetSearchArgs()
44+
if query == "" {
45+
query = req.GetQuery()
46+
}
4447
queryTerms := utils.SearchTermsFromQueryString(query)
4548

4649
for _, lib := range lm.Index.Libraries {

‎commands/lib/search_test.go

Copy file name to clipboardExpand all lines: commands/lib/search_test.go
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestSearchLibrary(t *testing.T) {
3333
lm := librariesmanager.NewLibraryManager(customIndexPath, nil)
3434
lm.LoadIndex()
3535

36-
resp := searchLibrary(&rpc.LibrarySearchRequest{Query: "test"}, lm)
36+
resp := searchLibrary(&rpc.LibrarySearchRequest{SearchArgs: "test"}, lm)
3737
assert := assert.New(t)
3838
assert.Equal(resp.GetStatus(), rpc.LibrarySearchStatus_LIBRARY_SEARCH_STATUS_SUCCESS)
3939
assert.Equal(len(resp.GetLibraries()), 2)
@@ -45,7 +45,7 @@ func TestSearchLibrarySimilar(t *testing.T) {
4545
lm := librariesmanager.NewLibraryManager(customIndexPath, nil)
4646
lm.LoadIndex()
4747

48-
resp := searchLibrary(&rpc.LibrarySearchRequest{Query: "arduino"}, lm)
48+
resp := searchLibrary(&rpc.LibrarySearchRequest{SearchArgs: "arduino"}, lm)
4949
assert := assert.New(t)
5050
assert.Equal(resp.GetStatus(), rpc.LibrarySearchStatus_LIBRARY_SEARCH_STATUS_SUCCESS)
5151
assert.Equal(len(resp.GetLibraries()), 2)
@@ -63,7 +63,7 @@ func TestSearchLibraryFields(t *testing.T) {
6363

6464
query := func(q string) []string {
6565
libs := []string{}
66-
for _, lib := range searchLibrary(&rpc.LibrarySearchRequest{Query: q}, lm).Libraries {
66+
for _, lib := range searchLibrary(&rpc.LibrarySearchRequest{SearchArgs: q}, lm).Libraries {
6767
libs = append(libs, lib.Name)
6868
}
6969
return libs

‎internal/cli/arguments/completion.go

Copy file name to clipboardExpand all lines: internal/cli/arguments/completion.go
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ func GetInstallableLibs() []string {
190190
inst := instance.CreateAndInit()
191191

192192
libs, _ := lib.LibrarySearch(context.Background(), &rpc.LibrarySearchRequest{
193-
Instance: inst,
194-
Query: "", // if no query is specified all the libs are returned
193+
Instance: inst,
194+
SearchArgs: "", // if no query is specified all the libs are returned
195195
})
196196
var res []string
197197
// transform the data structure for the completion

‎internal/cli/lib/args.go

Copy file name to clipboardExpand all lines: internal/cli/lib/args.go
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ func ParseLibraryReferenceArgs(args []string) ([]*LibraryReferenceArg, error) {
7777
func ParseLibraryReferenceArgAndAdjustCase(instance *rpc.Instance, arg string) (*LibraryReferenceArg, error) {
7878
libRef, _ := ParseLibraryReferenceArg(arg)
7979
res, err := lib.LibrarySearch(context.Background(), &rpc.LibrarySearchRequest{
80-
Instance: instance,
81-
Query: libRef.Name,
80+
Instance: instance,
81+
SearchArgs: libRef.Name,
8282
})
8383
if err != nil {
8484
return nil, err

‎internal/cli/lib/search.go

Copy file name to clipboardExpand all lines: internal/cli/lib/search.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func runSearchCommand(args []string, namesOnly bool, omitReleasesDetails bool) {
7676

7777
searchResp, err := lib.LibrarySearch(context.Background(), &rpc.LibrarySearchRequest{
7878
Instance: inst,
79-
Query: strings.Join(args, " "),
79+
SearchArgs: strings.Join(args, " "),
8080
OmitReleasesDetails: omitReleasesDetails,
8181
})
8282
if err != nil {

‎rpc/cc/arduino/cli/commands/v1/lib.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/lib.pb.go
+253-239Lines changed: 253 additions & 239 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/commands/v1/lib.proto

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/lib.proto
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,13 @@ message LibraryDependencyStatus {
137137
message LibrarySearchRequest {
138138
// Arduino Core Service instance from the `Init` response.
139139
Instance instance = 1;
140-
// The search query.
141-
string query = 2;
140+
// Deprecated. Use search_args instead.
141+
string query = 2 [ deprecated = true ];
142142
// Set to true to not populate the releases field in the response (may save a
143143
// lot of bandwidth/CPU).
144144
bool omit_releases_details = 3;
145+
// Keywords for the search.
146+
string search_args = 4;
145147
}
146148

147149
enum LibrarySearchStatus {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.