forked from okwme/modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query.go
48 lines (42 loc) · 1.23 KB
/
query.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
44
45
46
47
48
package cli
import (
"fmt"
"github.com/charleenfei/modules/incubator/faucet/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/spf13/cobra"
)
// GetQueryCmd returns the cli query commands for this module
func GetQueryCmd() *cobra.Command {
// Group pooltoy queries under a subcommand
pooltoyQueryCmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
pooltoyQueryCmd.AddCommand([]*cobra.Command{
queryWhenBrrr(),
}...)
return pooltoyQueryCmd
}
func queryWhenBrrr() *cobra.Command {
return &cobra.Command{
Use: "when-brrr [userAccount]",
Short: "how many seconds until this user can brrr again",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(ctx)
req := &types.QueryWhenBrrRequest{}
res, err := queryClient.QueryWhenBrr(cmd.Context(), req)
if err != nil {
return err
}
return ctx.PrintProto(res)
},
}
}