print all versions of tendermint and its sub protocols (#9329) (#9387)

(cherry picked from commit ffce253273)

Co-authored-by: Marko <marbar3778@yahoo.com>
This commit is contained in:
mergify[bot]
2022-09-07 09:25:43 -04:00
committed by GitHub
parent 014d0d6ca0
commit 6354c99dbf

View File

@@ -1,6 +1,7 @@
package commands package commands
import ( import (
"encoding/json"
"fmt" "fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@@ -13,6 +14,25 @@ var VersionCmd = &cobra.Command{
Use: "version", Use: "version",
Short: "Show version info", Short: "Show version info",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version.TMCoreSemVer) if verbose {
values, _ := json.MarshalIndent(struct {
Tendermint string `json:"tendermint"`
ABCI string `json:"abci"`
BlockProtocol uint64 `json:"block_protocol"`
P2PProtocol uint64 `json:"p2p_protocol"`
}{
Tendermint: version.TMCoreSemVer,
ABCI: version.ABCIVersion,
BlockProtocol: version.BlockProtocol,
P2PProtocol: version.P2PProtocol,
}, "", " ")
fmt.Println(string(values))
} else {
fmt.Println(version.TMCoreSemVer)
}
}, },
} }
func init() {
VersionCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Show protocol and library versions")
}