-
Notifications
You must be signed in to change notification settings - Fork 542
/
Copy pathsearch.go
43 lines (35 loc) · 906 Bytes
/
search.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cmd
import (
"github.com/majd/ipatool/v2/pkg/appstore"
"github.com/spf13/cobra"
)
// nolint:wrapcheck
func searchCmd() *cobra.Command {
var limit int64
cmd := &cobra.Command{
Use: "search <term>",
Short: "Search for iOS apps available on the App Store",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
infoResult, err := dependencies.AppStore.AccountInfo()
if err != nil {
return err
}
output, err := dependencies.AppStore.Search(appstore.SearchInput{
Account: infoResult.Account,
Term: args[0],
Limit: limit,
})
if err != nil {
return err
}
dependencies.Logger.Log().
Int("count", output.Count).
Array("apps", appstore.Apps(output.Results)).
Send()
return nil
},
}
cmd.Flags().Int64VarP(&limit, "limit", "l", 5, "maximum amount of search results to retrieve")
return cmd
}