Fixes #4284 Now prints: gaiacli query distr comission --trust-node cosmos1234 ERROR: unknown command "comission" for "distr" Did you mean this? commission Adds custom argument validation for subcommands with subcommands. Doesn't affect "query" or "tx" subcommands since they reside in gaia repo. All flags except help are disabled for these commands.
63 lines
1.9 KiB
Go
63 lines
1.9 KiB
Go
package client
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
amino "github.com/tendermint/go-amino"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
|
dist "github.com/cosmos/cosmos-sdk/x/distribution"
|
|
distCmds "github.com/cosmos/cosmos-sdk/x/distribution/client/cli"
|
|
)
|
|
|
|
// ModuleClient exports all client functionality from this module
|
|
type ModuleClient struct {
|
|
storeKey string
|
|
cdc *amino.Codec
|
|
}
|
|
|
|
func NewModuleClient(storeKey string, cdc *amino.Codec) ModuleClient {
|
|
return ModuleClient{storeKey, cdc}
|
|
}
|
|
|
|
// GetQueryCmd returns the cli query commands for this module
|
|
func (mc ModuleClient) GetQueryCmd() *cobra.Command {
|
|
distQueryCmd := &cobra.Command{
|
|
Use: dist.ModuleName,
|
|
Short: "Querying commands for the distribution module",
|
|
DisableFlagParsing: true,
|
|
SuggestionsMinimumDistance: 2,
|
|
RunE: utils.ValidateCmd,
|
|
}
|
|
|
|
distQueryCmd.AddCommand(client.GetCommands(
|
|
distCmds.GetCmdQueryParams(mc.storeKey, mc.cdc),
|
|
distCmds.GetCmdQueryValidatorOutstandingRewards(mc.storeKey, mc.cdc),
|
|
distCmds.GetCmdQueryValidatorCommission(mc.storeKey, mc.cdc),
|
|
distCmds.GetCmdQueryValidatorSlashes(mc.storeKey, mc.cdc),
|
|
distCmds.GetCmdQueryDelegatorRewards(mc.storeKey, mc.cdc),
|
|
distCmds.GetCmdQueryCommunityPool(mc.storeKey, mc.cdc),
|
|
)...)
|
|
|
|
return distQueryCmd
|
|
}
|
|
|
|
// GetTxCmd returns the transaction commands for this module
|
|
func (mc ModuleClient) GetTxCmd() *cobra.Command {
|
|
distTxCmd := &cobra.Command{
|
|
Use: dist.ModuleName,
|
|
Short: "Distribution transactions subcommands",
|
|
DisableFlagParsing: true,
|
|
SuggestionsMinimumDistance: 2,
|
|
RunE: utils.ValidateCmd,
|
|
}
|
|
|
|
distTxCmd.AddCommand(client.PostCommands(
|
|
distCmds.GetCmdWithdrawRewards(mc.cdc),
|
|
distCmds.GetCmdSetWithdrawAddr(mc.cdc),
|
|
distCmds.GetCmdWithdrawAllRewards(mc.cdc, mc.storeKey),
|
|
)...)
|
|
|
|
return distTxCmd
|
|
}
|