mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-03-30 15:08:28 +00:00
49 lines
1001 B
Go
49 lines
1001 B
Go
package cli
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var _ = strconv.Itoa(0)
|
|
|
|
func GetCmdDistributions() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "distributions",
|
|
Short: "Query distributions",
|
|
Args: cobra.ExactArgs(0),
|
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
queryClient := types.NewQueryClient(clientCtx)
|
|
|
|
params := &types.QueryDistributionsRequest{}
|
|
|
|
pageReq, err := client.ReadPageRequest(cmd.Flags())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
params.Pagination = pageReq
|
|
|
|
res, err := queryClient.Distributions(cmd.Context(), params)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return clientCtx.PrintProto(res)
|
|
},
|
|
}
|
|
|
|
flags.AddPaginationFlagsToCmd(cmd, cmd.Use)
|
|
flags.AddQueryFlagsToCmd(cmd)
|
|
|
|
return cmd
|
|
}
|