diff --git a/client/rpc/block.go b/client/rpc/block.go index 3547270197..36327a722a 100644 --- a/client/rpc/block.go +++ b/client/rpc/block.go @@ -16,7 +16,7 @@ const ( flagSelect = "select" ) -func blockCommand() *cobra.Command { +func BlockCommand() *cobra.Command { cmd := &cobra.Command{ Use: "block [height]", Short: "Get verified data for a the block at given height", diff --git a/client/rpc/root.go b/client/rpc/root.go index f779bd7292..e89972c3c7 100644 --- a/client/rpc/root.go +++ b/client/rpc/root.go @@ -26,8 +26,6 @@ func AddCommands(cmd *cobra.Command) { cmd.AddCommand( initClientCommand(), statusCommand(), - blockCommand(), - validatorCommand(), ) } diff --git a/client/rpc/validators.go b/client/rpc/validators.go index 892d131ac3..bfd8a9582b 100644 --- a/client/rpc/validators.go +++ b/client/rpc/validators.go @@ -14,7 +14,7 @@ import ( // TODO these next two functions feel kinda hacky based on their placement -func validatorCommand() *cobra.Command { +func ValidatorCommand() *cobra.Command { cmd := &cobra.Command{ Use: "validatorset [height]", Short: "Get the full validator set at given height", diff --git a/cmd/gaia/cmd/gaiacli/main.go b/cmd/gaia/cmd/gaiacli/main.go index 51dab68e28..4f82d58ad3 100644 --- a/cmd/gaia/cmd/gaiacli/main.go +++ b/cmd/gaia/cmd/gaiacli/main.go @@ -35,31 +35,73 @@ func main() { // the below functions and eliminate global vars, like we do // with the cdc - // add standard rpc, and tx commands + // add standard rpc commands rpc.AddCommands(rootCmd) rootCmd.AddCommand(client.LineBreak) - tx.AddCommands(rootCmd, cdc) - rootCmd.AddCommand(client.LineBreak) - // add query/post commands (custom to binary) + //Add state commands + stateCmd := &cobra.Command{ + Use: "state", + Short: "State querying subcommands (validators, blocks, transactions)", + } + stateCmd.AddCommand( + rpc.BlockCommand(), + rpc.ValidatorCommand(), + ) + tx.AddCommands(stateCmd, cdc) rootCmd.AddCommand( + stateCmd, + client.LineBreak, + ) + + //Add stake commands + stakeCmd := &cobra.Command{ + Use: "stake", + Short: "Stake and validation subcommands", + } + stakeCmd.AddCommand( client.GetCommands( - authcmd.GetAccountCmd("acc", cdc, authcmd.GetAccountDecoder(cdc)), stakecmd.GetCmdQueryValidator("stake", cdc), stakecmd.GetCmdQueryValidators("stake", cdc), stakecmd.GetCmdQueryDelegation("stake", cdc), stakecmd.GetCmdQueryDelegations("stake", cdc), )...) - rootCmd.AddCommand( + stakeCmd.AddCommand( client.PostCommands( - bankcmd.SendTxCmd(cdc), - ibccmd.IBCTransferCmd(cdc), - ibccmd.IBCRelayCmd(cdc), stakecmd.GetCmdCreateValidator(cdc), stakecmd.GetCmdEditValidator(cdc), stakecmd.GetCmdDelegate(cdc), stakecmd.GetCmdUnbond(cdc), )...) + rootCmd.AddCommand( + stakeCmd, + client.LineBreak, + ) + + //Add IBC commands + ibcCmd := &cobra.Command{ + Use: "ibc", + Short: "Inter-Blockchain Communication subcommands", + } + ibcCmd.AddCommand( + client.PostCommands( + ibccmd.IBCTransferCmd(cdc), + ibccmd.IBCRelayCmd(cdc), + )...) + rootCmd.AddCommand( + ibcCmd, + client.LineBreak, + ) + + //Add auth and bank commands + rootCmd.AddCommand( + client.GetCommands( + authcmd.GetAccountCmd("acc", cdc, authcmd.GetAccountDecoder(cdc)), + )...) + rootCmd.AddCommand( + client.PostCommands( + bankcmd.SendTxCmd(cdc), + )...) // add proxy, version and key info rootCmd.AddCommand( diff --git a/cmd/gaia/cmd/gaiad/main.go b/cmd/gaia/cmd/gaiad/main.go index f64498d850..30cb276ee1 100644 --- a/cmd/gaia/cmd/gaiad/main.go +++ b/cmd/gaia/cmd/gaiad/main.go @@ -17,6 +17,7 @@ import ( func main() { cdc := app.MakeCodec() ctx := server.NewDefaultContext() + cobra.EnableCommandSorting = false rootCmd := &cobra.Command{ Use: "gaiad", Short: "Gaia Daemon (server)", diff --git a/server/util.go b/server/util.go index f44cc2d728..da43dabbb1 100644 --- a/server/util.go +++ b/server/util.go @@ -9,6 +9,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/wire" tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" @@ -72,13 +73,25 @@ func AddCommands( rootCmd.PersistentFlags().String("log_level", ctx.Config.LogLevel, "Log level") - rootCmd.AddCommand( - InitCmd(ctx, cdc, appInit), - StartCmd(ctx, appCreator), + tendCmd := &cobra.Command{ + Use: "tendermint", + Short: "Tendermint subcommands", + } + + tendCmd.AddCommand( UnsafeResetAllCmd(ctx), ShowNodeIDCmd(ctx), ShowValidatorCmd(ctx), + ) + + rootCmd.AddCommand( + InitCmd(ctx, cdc, appInit), + StartCmd(ctx, appCreator), + client.LineBreak, + tendCmd, + client.LineBreak, ExportCmd(ctx, cdc, appExport), + client.LineBreak, version.VersionCmd, ) }