Skip to content

Commit 08e9d29

Browse files
fix objects browse command (#47)
1 parent d1e0559 commit 08e9d29

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

pkg/cmd/objects/browse/browse.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"io"
55

66
"github.com/MakeNowJust/heredoc"
7+
"github.com/algolia/algoliasearch-client-go/v3/algolia/opt"
78
"github.com/algolia/algoliasearch-client-go/v3/algolia/search"
89
"github.com/spf13/cobra"
910

@@ -71,7 +72,15 @@ func runBrowseCmd(opts *BrowseOptions) error {
7172
}
7273

7374
indice := client.InitIndex(opts.Indice)
74-
res, err := indice.BrowseObjects(opts.SearchParams)
75+
76+
// We use the `opt.ExtraOptions` to pass the `SearchParams` to the API.
77+
query, ok := opts.SearchParams["query"].(string)
78+
if !ok {
79+
query = ""
80+
} else {
81+
delete(opts.SearchParams, "query")
82+
}
83+
res, err := indice.BrowseObjects(opt.Query(query), opt.ExtraOptions(opts.SearchParams))
7584
if err != nil {
7685
return err
7786
}

0 commit comments

Comments
 (0)