Browse Source

cmd: hyphen-case cli v0.34.1 (#5786)

pull/5819/head
Callum Waters 4 years ago
committed by GitHub
parent
commit
9f0d71e81f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 55 additions and 28 deletions
  1. +2
    -0
      CHANGELOG_PENDING.md
  2. +5
    -3
      cmd/tendermint/commands/gen_node_key.go
  3. +5
    -3
      cmd/tendermint/commands/gen_validator.go
  4. +5
    -3
      cmd/tendermint/commands/probe_upnp.go
  5. +4
    -2
      cmd/tendermint/commands/replay.go
  6. +10
    -6
      cmd/tendermint/commands/reset_priv_validator.go
  7. +11
    -3
      cmd/tendermint/commands/root.go
  8. +3
    -2
      cmd/tendermint/commands/run_node.go
  9. +5
    -3
      cmd/tendermint/commands/show_node_id.go
  10. +5
    -3
      cmd/tendermint/commands/show_validator.go

+ 2
- 0
CHANGELOG_PENDING.md View File

@ -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


+ 5
- 3
cmd/tendermint/commands/gen_node_key.go View File

@ -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 {


+ 5
- 3
cmd/tendermint/commands/gen_validator.go View File

@ -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) {


+ 5
- 3
cmd/tendermint/commands/probe_upnp.go View File

@ -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 {


+ 4
- 2
cmd/tendermint/commands/replay.go View File

@ -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,
}

+ 10
- 6
cmd/tendermint/commands/reset_priv_validator.go View File

@ -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.


+ 11
- 3
cmd/tendermint/commands/root.go View File

@ -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")
}
}

+ 3
- 2
cmd/tendermint/commands/run_node.go View File

@ -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


+ 5
- 3
cmd/tendermint/commands/show_node_id.go View File

@ -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 {


+ 5
- 3
cmd/tendermint/commands/show_validator.go View File

@ -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 {


Loading…
Cancel
Save