diff --git a/CHANGELOG.md b/CHANGELOG.md index 696679d8..547ab568 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## Unreleased +### Improvements + +* [#175](https://github.com/babylonlabs-io/finality-provider/pull/175) adds: `eotsd version` command + ### Bug Fixes * [#166](https://github.com/babylonlabs-io/finality-provider/pull/166) fix: `eotsd keys add` `--output` flag diff --git a/eotsmanager/cmd/eotsd/daemon/root.go b/eotsmanager/cmd/eotsd/daemon/root.go index b4e88f57..590b83ee 100644 --- a/eotsmanager/cmd/eotsd/daemon/root.go +++ b/eotsmanager/cmd/eotsd/daemon/root.go @@ -1,6 +1,7 @@ package daemon import ( + "github.com/babylonlabs-io/finality-provider/version" "github.com/cosmos/cosmos-sdk/client" sdkflags "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" @@ -23,6 +24,7 @@ func NewRootCmd() *cobra.Command { NewInitCmd(), NewKeysCmd(), NewStartCmd(), + version.CommandVersion("eotsd"), ) return rootCmd diff --git a/finality-provider/cmd/fpd/daemon/daemon_commands.go b/finality-provider/cmd/fpd/daemon/daemon_commands.go index 2af31d26..7e54b207 100644 --- a/finality-provider/cmd/fpd/daemon/daemon_commands.go +++ b/finality-provider/cmd/fpd/daemon/daemon_commands.go @@ -2,22 +2,18 @@ package daemon import ( "context" + "cosmossdk.io/math" "encoding/hex" "encoding/json" "fmt" - "strconv" - "strings" - - "github.com/babylonlabs-io/finality-provider/finality-provider/proto" - fpversion "github.com/babylonlabs-io/finality-provider/version" - - "cosmossdk.io/math" "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/finality-provider/finality-provider/proto" "github.com/cosmos/cosmos-sdk/client" sdkflags "github.com/cosmos/cosmos-sdk/client/flags" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/spf13/cobra" "github.com/spf13/pflag" + "strconv" fpcmd "github.com/babylonlabs-io/finality-provider/finality-provider/cmd" fpcfg "github.com/babylonlabs-io/finality-provider/finality-provider/config" @@ -570,33 +566,3 @@ func loadKeyName(homeDir string, cmd *cobra.Command) (string, error) { } return keyName, nil } - -// CommandVersion prints cmd version -func CommandVersion() *cobra.Command { - var cmd = &cobra.Command{ - Use: "version", - Short: "Prints version of this binary.", - Aliases: []string{"v"}, - Example: `fpd version`, - Args: cobra.NoArgs, - Run: func(cmd *cobra.Command, _ []string) { - version := fpversion.Version() - commit, ts := fpversion.CommitInfo() - - if version == "" { - version = "main" - } - - var sb strings.Builder - _, _ = sb.WriteString("Version: " + version) - _, _ = sb.WriteString("\n") - _, _ = sb.WriteString("Git Commit: " + commit) - _, _ = sb.WriteString("\n") - _, _ = sb.WriteString("Git Timestamp: " + ts) - _, _ = sb.WriteString("\n") - - cmd.Printf(sb.String()) //nolint:govet // it's not an issue - }, - } - return cmd -} diff --git a/finality-provider/cmd/fpd/main.go b/finality-provider/cmd/fpd/main.go index fcebe405..8f101e93 100644 --- a/finality-provider/cmd/fpd/main.go +++ b/finality-provider/cmd/fpd/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "github.com/babylonlabs-io/finality-provider/version" "os" "github.com/cosmos/cosmos-sdk/client" @@ -34,7 +35,7 @@ func main() { daemon.CommandGetDaemonInfo(), daemon.CommandCreateFP(), daemon.CommandLsFP(), daemon.CommandInfoFP(), daemon.CommandRegisterFP(), daemon.CommandAddFinalitySig(), daemon.CommandExportFP(), daemon.CommandTxs(), daemon.CommandUnjailFP(), - daemon.CommandEditFinalityDescription(), daemon.CommandVersion(), + daemon.CommandEditFinalityDescription(), version.CommandVersion("fpd"), daemon.CommandCommitPubRand(), ) diff --git a/version/cmd.go b/version/cmd.go new file mode 100644 index 00000000..cb56880f --- /dev/null +++ b/version/cmd.go @@ -0,0 +1,37 @@ +package version + +import ( + "fmt" + "github.com/spf13/cobra" + "strings" +) + +// CommandVersion prints cmd version +func CommandVersion(binaryName string) *cobra.Command { + var cmd = &cobra.Command{ + Use: "version", + Short: "Prints version of this binary.", + Aliases: []string{"v"}, + Example: fmt.Sprintf("%s version", binaryName), + Args: cobra.NoArgs, + Run: func(cmd *cobra.Command, _ []string) { + v := Version() + commit, ts := CommitInfo() + + if v == "" { + v = "main" + } + + var sb strings.Builder + _, _ = sb.WriteString("Version: " + v) + _, _ = sb.WriteString("\n") + _, _ = sb.WriteString("Git Commit: " + commit) + _, _ = sb.WriteString("\n") + _, _ = sb.WriteString("Git Timestamp: " + ts) + _, _ = sb.WriteString("\n") + + cmd.Printf(sb.String()) //nolint:govet // it's not an issue + }, + } + return cmd +}