Skip to content

Commit 2bf58d7

Browse files
committed
add GetQueryCmdMembers
1 parent aebc9f3 commit 2bf58d7

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

x/bandtss/client/cli/query.go

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func GetQueryCmd() *cobra.Command {
2222

2323
cmd.AddCommand(
2424
GetQueryCmdMember(),
25+
GetQueryCmdMembers(),
2526
GetQueryCmdCurrentGroup(),
2627
GetQueryCmdParams(),
2728
GetQueryCmdSigning(),
@@ -62,12 +63,47 @@ func GetQueryCmdMember() *cobra.Command {
6263
return cmd
6364
}
6465

66+
// GetQueryCmdMembers creates a CLI command for querying members information.
67+
func GetQueryCmdMembers() *cobra.Command {
68+
cmd := &cobra.Command{
69+
Use: "members [is-active]",
70+
Short: "Query the members information of the active group",
71+
Args: cobra.ExactArgs(1),
72+
RunE: func(cmd *cobra.Command, args []string) error {
73+
clientCtx, err := client.GetClientQueryContext(cmd)
74+
if err != nil {
75+
return err
76+
}
77+
78+
isActive, err := strconv.ParseBool(args[0])
79+
if err != nil {
80+
return err
81+
}
82+
83+
queryClient := types.NewQueryClient(clientCtx)
84+
85+
res, err := queryClient.Members(cmd.Context(), &types.QueryMembersRequest{
86+
IsActive: isActive,
87+
})
88+
if err != nil {
89+
return err
90+
}
91+
92+
return clientCtx.PrintProto(res)
93+
},
94+
}
95+
96+
flags.AddQueryFlagsToCmd(cmd)
97+
98+
return cmd
99+
}
100+
65101
// GetQueryCmdCurrentGroup creates a CLI command for querying current group.
66102
func GetQueryCmdCurrentGroup() *cobra.Command {
67103
cmd := &cobra.Command{
68104
Use: "current-group",
69105
Short: "Query the currentGroup",
70-
Args: cobra.ExactArgs(0),
106+
Args: cobra.NoArgs,
71107
RunE: func(cmd *cobra.Command, args []string) error {
72108
clientCtx, err := client.GetClientQueryContext(cmd)
73109
if err != nil {
@@ -95,7 +131,7 @@ func GetQueryCmdParams() *cobra.Command {
95131
Use: "params",
96132
Short: "Show params",
97133
Long: "Show parameter of bandtss module",
98-
Args: cobra.ExactArgs(0),
134+
Args: cobra.NoArgs,
99135
RunE: func(cmd *cobra.Command, args []string) error {
100136
clientCtx, err := client.GetClientQueryContext(cmd)
101137
if err != nil {
@@ -154,7 +190,7 @@ func GetQueryCmdReplacement() *cobra.Command {
154190
cmd := &cobra.Command{
155191
Use: "replacement",
156192
Short: "Query the replacement information",
157-
Args: cobra.ExactArgs(0),
193+
Args: cobra.NoArgs,
158194
RunE: func(cmd *cobra.Command, args []string) error {
159195
clientCtx, err := client.GetClientQueryContext(cmd)
160196
if err != nil {

0 commit comments

Comments
 (0)