@@ -12,20 +12,21 @@ import (
12
12
"github.com/algolia/cli/pkg/iostreams"
13
13
)
14
14
15
- type ExportOptions struct {
15
+ type BrowseOptions struct {
16
16
Config * config.Config
17
17
IO * iostreams.IOStreams
18
18
19
19
SearchClient func () (* search.Client , error )
20
20
21
- PrintFlags * cmdutil.PrintFlags
21
+ Indice string
22
+ SearchParams map [string ]interface {}
22
23
23
- Index string
24
+ PrintFlags * cmdutil. PrintFlags
24
25
}
25
26
26
27
// NewBrowseCmd creates and returns a browse command for index objects
27
28
func NewBrowseCmd (f * cmdutil.Factory ) * cobra.Command {
28
- opts := & ExportOptions {
29
+ opts := & BrowseOptions {
29
30
IO : f .IOStreams ,
30
31
Config : f .Config ,
31
32
SearchClient : f .SearchClient ,
@@ -45,25 +46,32 @@ func NewBrowseCmd(f *cmdutil.Factory) *cobra.Command {
45
46
$ algolia objects browse TEST_PRODUCTS_1
46
47
` ),
47
48
RunE : func (cmd * cobra.Command , args []string ) error {
48
- opts .Index = args [0 ]
49
+ opts .Indice = args [0 ]
50
+
51
+ searchParams , err := cmdutil .FlagValuesMap (cmd .Flags (), cmdutil .SearchParams ... )
52
+ if err != nil {
53
+ return err
54
+ }
55
+ opts .SearchParams = searchParams
49
56
50
57
return runBrowseCmd (opts )
51
58
},
52
59
}
53
60
61
+ cmdutil .AddSearchFlags (cmd )
54
62
opts .PrintFlags .AddFlags (cmd )
55
63
56
64
return cmd
57
65
}
58
66
59
- func runBrowseCmd (opts * ExportOptions ) error {
67
+ func runBrowseCmd (opts * BrowseOptions ) error {
60
68
client , err := opts .SearchClient ()
61
69
if err != nil {
62
70
return err
63
71
}
64
72
65
- indice := client .InitIndex (opts .Index )
66
- res , err := indice .BrowseObjects ()
73
+ indice := client .InitIndex (opts .Indice )
74
+ res , err := indice .BrowseObjects (opts . SearchParams )
67
75
if err != nil {
68
76
return err
69
77
}
0 commit comments