diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 1a8112718..260963771 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -10,6 +10,8 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi - CLI/RPC/Config + - [cli] \#5786 deprecate snake_case commands for hyphen-case (@cmwaters) + - Apps - P2P Protocol diff --git a/cmd/tendermint/commands/gen_node_key.go b/cmd/tendermint/commands/gen_node_key.go index e9f1f8103..dd4eee740 100644 --- a/cmd/tendermint/commands/gen_node_key.go +++ b/cmd/tendermint/commands/gen_node_key.go @@ -12,9 +12,11 @@ import ( // GenNodeKeyCmd allows the generation of a node key. It prints node's ID to // the standard output. var GenNodeKeyCmd = &cobra.Command{ - Use: "gen_node_key", - Short: "Generate a node key for this node and print its ID", - RunE: genNodeKey, + Use: "gen-node-key", + Aliases: []string{"gen_node_key"}, + Short: "Generate a node key for this node and print its ID", + PreRun: deprecateSnakeCase, + RunE: genNodeKey, } func genNodeKey(cmd *cobra.Command, args []string) error { diff --git a/cmd/tendermint/commands/gen_validator.go b/cmd/tendermint/commands/gen_validator.go index 41020a5be..3b3336fcd 100644 --- a/cmd/tendermint/commands/gen_validator.go +++ b/cmd/tendermint/commands/gen_validator.go @@ -12,9 +12,11 @@ import ( // GenValidatorCmd allows the generation of a keypair for a // validator. var GenValidatorCmd = &cobra.Command{ - Use: "gen_validator", - Short: "Generate new validator keypair", - Run: genValidator, + Use: "gen-validator", + Aliases: []string{"gen_validator"}, + Short: "Generate new validator keypair", + PreRun: deprecateSnakeCase, + Run: genValidator, } func genValidator(cmd *cobra.Command, args []string) { diff --git a/cmd/tendermint/commands/probe_upnp.go b/cmd/tendermint/commands/probe_upnp.go index 9ac35fd50..7d0193c84 100644 --- a/cmd/tendermint/commands/probe_upnp.go +++ b/cmd/tendermint/commands/probe_upnp.go @@ -11,9 +11,11 @@ import ( // ProbeUpnpCmd adds capabilities to test the UPnP functionality. var ProbeUpnpCmd = &cobra.Command{ - Use: "probe_upnp", - Short: "Test UPnP functionality", - RunE: probeUpnp, + Use: "probe-upnp", + Aliases: []string{"probe_upnp"}, + Short: "Test UPnP functionality", + RunE: probeUpnp, + PreRun: deprecateSnakeCase, } func probeUpnp(cmd *cobra.Command, args []string) error { diff --git a/cmd/tendermint/commands/replay.go b/cmd/tendermint/commands/replay.go index 303ccba6b..5de8d0d3e 100644 --- a/cmd/tendermint/commands/replay.go +++ b/cmd/tendermint/commands/replay.go @@ -18,9 +18,11 @@ var ReplayCmd = &cobra.Command{ // ReplayConsoleCmd allows replaying of messages from the WAL in a // console. var ReplayConsoleCmd = &cobra.Command{ - Use: "replay_console", - Short: "Replay messages from WAL in a console", + Use: "replay-console", + Aliases: []string{"replay_console"}, + Short: "Replay messages from WAL in a console", Run: func(cmd *cobra.Command, args []string) { consensus.RunReplayFile(config.BaseConfig, config.Consensus, true) }, + PreRun: deprecateSnakeCase, } diff --git a/cmd/tendermint/commands/reset_priv_validator.go b/cmd/tendermint/commands/reset_priv_validator.go index beefee5cb..45b86d44c 100644 --- a/cmd/tendermint/commands/reset_priv_validator.go +++ b/cmd/tendermint/commands/reset_priv_validator.go @@ -13,9 +13,11 @@ import ( // ResetAllCmd removes the database of this Tendermint core // instance. var ResetAllCmd = &cobra.Command{ - Use: "unsafe_reset_all", - Short: "(unsafe) Remove all the data and WAL, reset this node's validator to genesis state", - Run: resetAll, + Use: "unsafe-reset-all", + Aliases: []string{"unsafe_reset_all"}, + Short: "(unsafe) Remove all the data and WAL, reset this node's validator to genesis state", + Run: resetAll, + PreRun: deprecateSnakeCase, } var keepAddrBook bool @@ -26,9 +28,11 @@ func init() { // ResetPrivValidatorCmd resets the private validator files. var ResetPrivValidatorCmd = &cobra.Command{ - Use: "unsafe_reset_priv_validator", - Short: "(unsafe) Reset this node's validator to genesis state", - Run: resetPrivValidator, + Use: "unsafe-reset-priv-validator", + Aliases: []string{"unsafe_reset_priv_validator"}, + Short: "(unsafe) Reset this node's validator to genesis state", + Run: resetPrivValidator, + PreRun: deprecateSnakeCase, } // XXX: this is totally unsafe. diff --git a/cmd/tendermint/commands/root.go b/cmd/tendermint/commands/root.go index 664f8ff14..b0e446c4c 100644 --- a/cmd/tendermint/commands/root.go +++ b/cmd/tendermint/commands/root.go @@ -3,6 +3,7 @@ package commands import ( "fmt" "os" + "strings" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -36,16 +37,16 @@ func ParseConfig() (*cfg.Config, error) { } conf.SetRoot(conf.RootDir) cfg.EnsureRoot(conf.RootDir) - if err = conf.ValidateBasic(); err != nil { + if err := conf.ValidateBasic(); err != nil { return nil, fmt.Errorf("error in config file: %v", err) } - return conf, err + return conf, nil } // RootCmd is the root command for Tendermint core. var RootCmd = &cobra.Command{ Use: "tendermint", - Short: "Tendermint Core (BFT Consensus) in Go", + Short: "BFT state machine replication for applications in any programming languages", PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) { if cmd.Name() == VersionCmd.Name() { return nil @@ -68,3 +69,10 @@ var RootCmd = &cobra.Command{ return nil }, } + +// deprecateSnakeCase is a util function for 0.34.1. Should be removed in 0.35 +func deprecateSnakeCase(cmd *cobra.Command, args []string) { + if strings.Contains(cmd.CalledAs(), "_") { + fmt.Println("Deprecated: snake_case commands will be replaced by hyphen-case commands in the next major release") + } +} diff --git a/cmd/tendermint/commands/run_node.go b/cmd/tendermint/commands/run_node.go index af77553fa..acc79920a 100644 --- a/cmd/tendermint/commands/run_node.go +++ b/cmd/tendermint/commands/run_node.go @@ -99,8 +99,9 @@ func AddNodeFlags(cmd *cobra.Command) { // It can be used with a custom PrivValidator and in-process ABCI application. func NewRunNodeCmd(nodeProvider nm.Provider) *cobra.Command { cmd := &cobra.Command{ - Use: "node", - Short: "Run the tendermint node", + Use: "start", + Aliases: []string{"node", "run"}, + Short: "Run the tendermint node", RunE: func(cmd *cobra.Command, args []string) error { if err := checkGenesisHash(config); err != nil { return err diff --git a/cmd/tendermint/commands/show_node_id.go b/cmd/tendermint/commands/show_node_id.go index 6026e3e18..26c097490 100644 --- a/cmd/tendermint/commands/show_node_id.go +++ b/cmd/tendermint/commands/show_node_id.go @@ -10,9 +10,11 @@ import ( // ShowNodeIDCmd dumps node's ID to the standard output. var ShowNodeIDCmd = &cobra.Command{ - Use: "show_node_id", - Short: "Show this node's ID", - RunE: showNodeID, + Use: "show-node-id", + Aliases: []string{"show_node_id"}, + Short: "Show this node's ID", + RunE: showNodeID, + PreRun: deprecateSnakeCase, } func showNodeID(cmd *cobra.Command, args []string) error { diff --git a/cmd/tendermint/commands/show_validator.go b/cmd/tendermint/commands/show_validator.go index e3980743a..f29976bb3 100644 --- a/cmd/tendermint/commands/show_validator.go +++ b/cmd/tendermint/commands/show_validator.go @@ -12,9 +12,11 @@ import ( // ShowValidatorCmd adds capabilities for showing the validator info. var ShowValidatorCmd = &cobra.Command{ - Use: "show_validator", - Short: "Show this node's validator info", - RunE: showValidator, + Use: "show-validator", + Aliases: []string{"show_validator"}, + Short: "Show this node's validator info", + RunE: showValidator, + PreRun: deprecateSnakeCase, } func showValidator(cmd *cobra.Command, args []string) error {