-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize CLI command structure. Fixes #2575
- Loading branch information
1 parent
8f690b5
commit d4fb6d4
Showing
8 changed files
with
193 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/rpc" | ||
"github.com/cosmos/cosmos-sdk/client/tx" | ||
"github.com/spf13/cobra" | ||
|
||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" | ||
govcmd "github.com/cosmos/cosmos-sdk/x/gov/client/cli" | ||
slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli" | ||
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli" | ||
amino "github.com/tendermint/go-amino" | ||
) | ||
|
||
func queryCmd(cdc *amino.Codec) *cobra.Command { | ||
//Add query commands | ||
queryCmd := &cobra.Command{ | ||
Use: "query", | ||
Aliases: []string{"q"}, | ||
Short: "Querying subcommands", | ||
} | ||
|
||
// Group staking queries under a subcommand | ||
stakeQueryCmd := &cobra.Command{ | ||
Use: "stake", | ||
Short: "Querying commands for staking module", | ||
} | ||
|
||
stakeQueryCmd.AddCommand(client.GetCommands( | ||
stakecmd.GetCmdQueryDelegation(storeStake, cdc), | ||
stakecmd.GetCmdQueryDelegations(storeStake, cdc), | ||
stakecmd.GetCmdQueryUnbondingDelegation(storeStake, cdc), | ||
stakecmd.GetCmdQueryUnbondingDelegations(storeStake, cdc), | ||
stakecmd.GetCmdQueryRedelegation(storeStake, cdc), | ||
stakecmd.GetCmdQueryRedelegations(storeStake, cdc), | ||
stakecmd.GetCmdQueryValidator(storeStake, cdc), | ||
stakecmd.GetCmdQueryValidators(storeStake, cdc), | ||
stakecmd.GetCmdQueryValidatorUnbondingDelegations(queryRouteStake, cdc), | ||
stakecmd.GetCmdQueryValidatorRedelegations(queryRouteStake, cdc), | ||
stakecmd.GetCmdQueryParams(storeStake, cdc), | ||
stakecmd.GetCmdQueryPool(storeStake, cdc))...) | ||
|
||
// Group gov queries under a subcommand | ||
govQueryCmd := &cobra.Command{ | ||
Use: "gov", | ||
Short: "Querying commands for gov module", | ||
} | ||
|
||
govQueryCmd.AddCommand(client.GetCommands( | ||
govcmd.GetCmdQueryProposal(storeGov, cdc), | ||
govcmd.GetCmdQueryProposals(storeGov, cdc), | ||
govcmd.GetCmdQueryVote(storeGov, cdc), | ||
govcmd.GetCmdQueryVotes(storeGov, cdc), | ||
govcmd.GetCmdQueryDeposit(storeGov, cdc), | ||
govcmd.GetCmdQueryDeposits(storeGov, cdc))...) | ||
|
||
// Group slashing queries under a subcommand | ||
slashingQueryCmd := &cobra.Command{ | ||
Use: "slashing", | ||
Short: "Querying commands for slashing module", | ||
} | ||
|
||
slashingQueryCmd.AddCommand(client.GetCommands( | ||
slashingcmd.GetCmdQuerySigningInfo(storeSlashing, cdc))...) | ||
|
||
// Query commcmmand sturcture | ||
queryCmd.AddCommand( | ||
rpc.BlockCommand(), | ||
rpc.ValidatorCommand(), | ||
tx.SearchTxCmd(cdc), | ||
tx.QueryTxCmd(cdc), | ||
client.LineBreak, | ||
authcmd.GetAccountCmd(storeAcc, cdc, authcmd.GetAccountDecoder(cdc)), | ||
stakeQueryCmd, | ||
govQueryCmd, | ||
slashingQueryCmd, | ||
) | ||
|
||
return queryCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/spf13/cobra" | ||
|
||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" | ||
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli" | ||
distrcmd "github.com/cosmos/cosmos-sdk/x/distribution/client/cli" | ||
govcmd "github.com/cosmos/cosmos-sdk/x/gov/client/cli" | ||
slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli" | ||
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli" | ||
amino "github.com/tendermint/go-amino" | ||
) | ||
|
||
func txCmd(cdc *amino.Codec) *cobra.Command { | ||
//Add transaction generation commands | ||
txCmd := &cobra.Command{ | ||
Use: "tx", | ||
Short: "Transactions subcommands", | ||
} | ||
|
||
stakeTxCmd := &cobra.Command{ | ||
Use: "stake", | ||
Short: "Stake Transactions subcommands", | ||
} | ||
|
||
stakeTxCmd.AddCommand(client.PostCommands( | ||
stakecmd.GetCmdCreateValidator(cdc), | ||
stakecmd.GetCmdEditValidator(cdc), | ||
stakecmd.GetCmdDelegate(cdc), | ||
stakecmd.GetCmdRedelegate(storeStake, cdc), | ||
stakecmd.GetCmdUnbond(storeStake, cdc), | ||
)...) | ||
|
||
distTxCmd := &cobra.Command{ | ||
Use: "dist", | ||
Short: "Distribution Transactions subcommands", | ||
} | ||
|
||
distTxCmd.AddCommand(client.PostCommands( | ||
distrcmd.GetCmdWithdrawRewards(cdc), | ||
distrcmd.GetCmdSetWithdrawAddr(cdc), | ||
)...) | ||
|
||
govTxCmd := &cobra.Command{ | ||
Use: "gov", | ||
Short: "Governance Transactions subcommands", | ||
} | ||
|
||
govTxCmd.AddCommand(client.PostCommands( | ||
govcmd.GetCmdDeposit(cdc), | ||
govcmd.GetCmdVote(cdc), | ||
govcmd.GetCmdSubmitProposal(cdc), | ||
)...) | ||
|
||
slashingTxCmd := &cobra.Command{ | ||
Use: "slashing", | ||
Short: "Slashing Transactions subcommands", | ||
} | ||
|
||
slashingTxCmd.AddCommand(client.PostCommands( | ||
slashingcmd.GetCmdUnjail(cdc), | ||
)...) | ||
|
||
txCmd.AddCommand( | ||
//Add auth and bank commands | ||
client.PostCommands( | ||
bankcmd.SendTxCmd(cdc), | ||
bankcmd.GetBroadcastCommand(cdc), | ||
authcmd.GetSignCommand(cdc, authcmd.GetAccountDecoder(cdc)), | ||
)...) | ||
|
||
txCmd.AddCommand( | ||
client.LineBreak, | ||
stakeTxCmd, | ||
distTxCmd, | ||
govTxCmd, | ||
slashingTxCmd, | ||
) | ||
|
||
return txCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters