mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-02 10:02:14 +00:00
Remove encoding from common cli
This commit is contained in:
parent
13f009bf68
commit
bcd8d403dc
22
cli/setup.go
22
cli/setup.go
@ -8,9 +8,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
data "github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/go-wire/data/base58"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -42,7 +39,7 @@ func PrepareBaseCmd(cmd *cobra.Command, envPrefix, defaultHome string) Executor
|
||||
func PrepareMainCmd(cmd *cobra.Command, envPrefix, defaultHome string) Executor {
|
||||
cmd.PersistentFlags().StringP(EncodingFlag, "e", "hex", "Binary encoding (hex|b64|btc)")
|
||||
cmd.PersistentFlags().StringP(OutputFlag, "o", "text", "Output format (text|json)")
|
||||
cmd.PersistentPreRunE = concatCobraCmdFuncs(setEncoding, validateOutput, cmd.PersistentPreRunE)
|
||||
cmd.PersistentPreRunE = concatCobraCmdFuncs(validateOutput, cmd.PersistentPreRunE)
|
||||
return PrepareBaseCmd(cmd, envPrefix, defaultHome)
|
||||
}
|
||||
|
||||
@ -147,23 +144,6 @@ func bindFlagsLoadViper(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// setEncoding reads the encoding flag
|
||||
func setEncoding(cmd *cobra.Command, args []string) error {
|
||||
// validate and set encoding
|
||||
enc := viper.GetString("encoding")
|
||||
switch enc {
|
||||
case "hex":
|
||||
data.Encoder = data.HexEncoder
|
||||
case "b64":
|
||||
data.Encoder = data.B64Encoder
|
||||
case "btc":
|
||||
data.Encoder = base58.BTCEncoder
|
||||
default:
|
||||
return errors.Errorf("Unsupported encoding: %s", enc)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateOutput(cmd *cobra.Command, args []string) error {
|
||||
// validate output format
|
||||
output := viper.GetString(OutputFlag)
|
||||
|
Loading…
x
Reference in New Issue
Block a user