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.
55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package client
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
amino "github.com/tendermint/go-amino"
|
|
|
|
sdkclient "github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
|
"github.com/cosmos/cosmos-sdk/x/mint"
|
|
"github.com/cosmos/cosmos-sdk/x/mint/client/cli"
|
|
)
|
|
|
|
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 the minting module.
|
|
func (mc ModuleClient) GetQueryCmd() *cobra.Command {
|
|
mintingQueryCmd := &cobra.Command{
|
|
Use: mint.ModuleName,
|
|
Short: "Querying commands for the minting module",
|
|
DisableFlagParsing: true,
|
|
SuggestionsMinimumDistance: 2,
|
|
RunE: utils.ValidateCmd,
|
|
}
|
|
|
|
mintingQueryCmd.AddCommand(
|
|
sdkclient.GetCommands(
|
|
cli.GetCmdQueryParams(mc.cdc),
|
|
cli.GetCmdQueryInflation(mc.cdc),
|
|
cli.GetCmdQueryAnnualProvisions(mc.cdc),
|
|
)...,
|
|
)
|
|
|
|
return mintingQueryCmd
|
|
}
|
|
|
|
// GetTxCmd returns the transaction commands for the minting module.
|
|
func (mc ModuleClient) GetTxCmd() *cobra.Command {
|
|
mintTxCmd := &cobra.Command{
|
|
Use: mint.ModuleName,
|
|
Short: "Minting transaction subcommands",
|
|
DisableFlagParsing: true,
|
|
SuggestionsMinimumDistance: 2,
|
|
RunE: utils.ValidateCmd,
|
|
}
|
|
|
|
return mintTxCmd
|
|
}
|