github.com/lino-network/lino@v0.6.11/x/vote/client/cli/query.go (about)

     1  package cli
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/cosmos/cosmos-sdk/client"
     7  	"github.com/cosmos/cosmos-sdk/codec"
     8  	"github.com/spf13/cobra"
     9  
    10  	// linotypes "github.com/lino-network/lino/types"
    11  	"github.com/lino-network/lino/utils"
    12  	"github.com/lino-network/lino/x/vote/model"
    13  	types "github.com/lino-network/lino/x/vote/types"
    14  )
    15  
    16  func GetQueryCmd(cdc *codec.Codec) *cobra.Command {
    17  	cmd := &cobra.Command{
    18  		Use:                        types.ModuleName,
    19  		Short:                      "Querying commands for the vote module",
    20  		DisableFlagParsing:         true,
    21  		SuggestionsMinimumDistance: 2,
    22  		RunE:                       client.ValidateCmd,
    23  	}
    24  	cmd.AddCommand(client.GetCommands(
    25  		getCmdVoter(cdc),
    26  		utils.SimpleQueryCmd(
    27  			"stake-stats <day>", "stake-stats <day>",
    28  			types.QuerierRoute, types.QueryStakeStats,
    29  			1, &model.LinoStakeStat{})(cdc),
    30  	)...)
    31  	return cmd
    32  }
    33  
    34  // GetCmdVoter -
    35  func getCmdVoter(cdc *codec.Codec) *cobra.Command {
    36  	return &cobra.Command{
    37  		Use:   "voter",
    38  		Short: "voter [username]",
    39  		Args:  cobra.ExactArgs(1),
    40  		RunE: func(cmd *cobra.Command, args []string) error {
    41  			user := args[0]
    42  			uri := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryVoter, user)
    43  			rst := model.Voter{}
    44  			return utils.CLIQueryJSONPrint(cdc, uri, nil,
    45  				func() interface{} { return &rst })
    46  		},
    47  	}
    48  }