github.com/lino-network/lino@v0.6.11/x/post/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/post/model"
    13  	"github.com/lino-network/lino/x/post/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 post module",
    20  		DisableFlagParsing:         true,
    21  		SuggestionsMinimumDistance: 2,
    22  		RunE:                       client.ValidateCmd,
    23  	}
    24  	cmd.AddCommand(client.GetCommands(
    25  		getCmdInfo(cdc),
    26  		utils.SimpleQueryCmd(
    27  			"cw",
    28  			"cw prints the consumption competition metadata, unit: miniDollar",
    29  			types.QuerierRoute, types.QueryConsumptionWindow, 0, &linotypes.MiniDollar{})(cdc),
    30  	)...)
    31  	return cmd
    32  }
    33  
    34  // GetCmdInfo -
    35  func getCmdInfo(cdc *codec.Codec) *cobra.Command {
    36  	return &cobra.Command{
    37  		Use:   "info <permlink>",
    38  		Short: "info <permlink>",
    39  		Args:  cobra.ExactArgs(1),
    40  		RunE: func(cmd *cobra.Command, args []string) error {
    41  			permlink := args[0]
    42  			uri := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryPostInfo, permlink)
    43  			rst := model.Post{}
    44  			return utils.CLIQueryJSONPrint(cdc, uri, nil,
    45  				func() interface{} { return &rst })
    46  		},
    47  	}
    48  }