diff --git a/CHANGELOG.md b/CHANGELOG.md index 037cf63078..e23165799f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Pending BREAKING CHANGES +* [cli] rearranged commands under subcommands FEATURES diff --git a/client/rpc/block.go b/client/rpc/block.go index 3547270197..693298bb86 100644 --- a/client/rpc/block.go +++ b/client/rpc/block.go @@ -16,7 +16,8 @@ const ( flagSelect = "select" ) -func blockCommand() *cobra.Command { +//BlockCommand returns the verified block data for a given heights +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..27b7fce99e 100644 --- a/client/rpc/validators.go +++ b/client/rpc/validators.go @@ -14,10 +14,11 @@ import ( // TODO these next two functions feel kinda hacky based on their placement -func validatorCommand() *cobra.Command { +//ValidatorCommand returns the validator set for a given height +func ValidatorCommand() *cobra.Command { cmd := &cobra.Command{ Use: "validatorset [height]", - Short: "Get the full validator set at given height", + Short: "Get the full tendermint validator set at given height", Args: cobra.MaximumNArgs(1), RunE: printValidators, } diff --git a/cmd/gaia/cli_test/cli_test.go b/cmd/gaia/cli_test/cli_test.go index 8fa0ad71ec..a591c9903f 100644 --- a/cmd/gaia/cli_test/cli_test.go +++ b/cmd/gaia/cli_test/cli_test.go @@ -96,7 +96,7 @@ func TestGaiaCLICreateValidator(t *testing.T) { require.NoError(t, err) executeWrite(t, fmt.Sprintf("gaiacli send %v --amount=10steak --to=%v --name=foo", flags, barCech), pass) - time.Sleep(time.Second * 2) // waiting for some blocks to pass + time.Sleep(time.Second * 3) // waiting for some blocks to pass barAcc := executeGetAccount(t, fmt.Sprintf("gaiacli account %v %v", barCech, flags)) assert.Equal(t, int64(10), barAcc.GetCoins().AmountOf("steak")) @@ -104,7 +104,7 @@ func TestGaiaCLICreateValidator(t *testing.T) { assert.Equal(t, int64(40), fooAcc.GetCoins().AmountOf("steak")) // create validator - cvStr := fmt.Sprintf("gaiacli create-validator %v", flags) + cvStr := fmt.Sprintf("gaiacli stake create-validator %v", flags) cvStr += fmt.Sprintf(" --name=%v", "bar") cvStr += fmt.Sprintf(" --address-validator=%v", barCech) cvStr += fmt.Sprintf(" --pubkey=%v", barCeshPubKey) @@ -117,12 +117,12 @@ func TestGaiaCLICreateValidator(t *testing.T) { barAcc = executeGetAccount(t, fmt.Sprintf("gaiacli account %v %v", barCech, flags)) require.Equal(t, int64(8), barAcc.GetCoins().AmountOf("steak"), "%v", barAcc) - validator := executeGetValidator(t, fmt.Sprintf("gaiacli validator %v --output=json %v", barCech, flags)) + validator := executeGetValidator(t, fmt.Sprintf("gaiacli stake validator %v --output=json %v", barCech, flags)) assert.Equal(t, validator.Owner, barAddr) assert.Equal(t, "2/1", validator.PoolShares.Amount.String()) // unbond a single share - unbondStr := fmt.Sprintf("gaiacli unbond %v", flags) + unbondStr := fmt.Sprintf("gaiacli stake unbond %v", flags) unbondStr += fmt.Sprintf(" --name=%v", "bar") unbondStr += fmt.Sprintf(" --address-validator=%v", barCech) unbondStr += fmt.Sprintf(" --address-delegator=%v", barCech) @@ -135,7 +135,7 @@ func TestGaiaCLICreateValidator(t *testing.T) { barAcc = executeGetAccount(t, fmt.Sprintf("gaiacli account %v %v", barCech, flags)) require.Equal(t, int64(9), barAcc.GetCoins().AmountOf("steak"), "%v", barAcc) - validator = executeGetValidator(t, fmt.Sprintf("gaiacli validator %v --output=json %v", barCech, flags)) + validator = executeGetValidator(t, fmt.Sprintf("gaiacli stake validator %v --output=json %v", barCech, flags)) assert.Equal(t, "1/1", validator.PoolShares.Amount.String()) } diff --git a/cmd/gaia/cmd/gaiacli/main.go b/cmd/gaia/cmd/gaiacli/main.go index 51dab68e28..049c07b364 100644 --- a/cmd/gaia/cmd/gaiacli/main.go +++ b/cmd/gaia/cmd/gaiacli/main.go @@ -35,36 +35,81 @@ 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 + tendermintCmd := &cobra.Command{ + Use: "tendermint", + Short: "Tendermint state querying subcommands", + } + tendermintCmd.AddCommand( + rpc.BlockCommand(), + rpc.ValidatorCommand(), + ) + tx.AddCommands(tendermintCmd, cdc) + + //Add IBC commands + ibcCmd := &cobra.Command{ + Use: "ibc", + Short: "Inter-Blockchain Communication subcommands", + } + ibcCmd.AddCommand( + client.PostCommands( + ibccmd.IBCTransferCmd(cdc), + ibccmd.IBCRelayCmd(cdc), + )...) + + advancedCmd := &cobra.Command{ + Use: "advanced", + Short: "Advanced subcommands", + } + + advancedCmd.AddCommand( + tendermintCmd, + ibcCmd, + lcd.ServeCommand(cdc), + ) rootCmd.AddCommand( + advancedCmd, + 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, + ) + + //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( - client.LineBreak, - lcd.ServeCommand(cdc), keys.Commands(), client.LineBreak, version.VersionCmd, 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..9e705f8792 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,24 @@ func AddCommands( rootCmd.PersistentFlags().String("log_level", ctx.Config.LogLevel, "Log level") + tendermintCmd := &cobra.Command{ + Use: "tendermint", + Short: "Tendermint subcommands", + } + + tendermintCmd.AddCommand( + ShowNodeIDCmd(ctx), + ShowValidatorCmd(ctx), + ) + rootCmd.AddCommand( InitCmd(ctx, cdc, appInit), StartCmd(ctx, appCreator), UnsafeResetAllCmd(ctx), - ShowNodeIDCmd(ctx), - ShowValidatorCmd(ctx), + client.LineBreak, + tendermintCmd, ExportCmd(ctx, cdc, appExport), + client.LineBreak, version.VersionCmd, ) }