cosmos-sdk/x/slashing/client/module_client.go
colin axner 6e2f5f3102 R4R: Support "unknown commands" for subcommands (#4465)
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.
2019-06-04 18:07:12 +01:00

61 lines
1.6 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"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/slashing/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 {
// Group slashing queries under a subcommand
slashingQueryCmd := &cobra.Command{
Use: slashing.ModuleName,
Short: "Querying commands for the slashing module",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: utils.ValidateCmd,
}
slashingQueryCmd.AddCommand(
client.GetCommands(
cli.GetCmdQuerySigningInfo(mc.storeKey, mc.cdc),
cli.GetCmdQueryParams(mc.cdc),
)...,
)
return slashingQueryCmd
}
// GetTxCmd returns the transaction commands for this module
func (mc ModuleClient) GetTxCmd() *cobra.Command {
slashingTxCmd := &cobra.Command{
Use: slashing.ModuleName,
Short: "Slashing transactions subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: utils.ValidateCmd,
}
slashingTxCmd.AddCommand(client.PostCommands(
cli.GetCmdUnjail(mc.cdc),
)...)
return slashingTxCmd
}