From eb67b61c0f561f8f9bbfeb6461e00c04be18920a Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 27 Jul 2022 16:28:40 +0300 Subject: [PATCH] cli: change --version output format, fix #2611 --- cli/main.go | 10 ++++++++++ cli/main_test.go | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cli/main.go b/cli/main.go index 5c35efa42..f854c43cc 100644 --- a/cli/main.go +++ b/cli/main.go @@ -1,7 +1,9 @@ package main import ( + "fmt" "os" + "runtime" "github.com/nspcc-dev/neo-go/cli/query" "github.com/nspcc-dev/neo-go/cli/server" @@ -21,7 +23,15 @@ func main() { } } +func versionPrinter(c *cli.Context) { + _, _ = fmt.Fprintf(c.App.Writer, "NeoGo\nVersion: %s\nGoVersion: %s\n", + config.Version, + runtime.Version(), + ) +} + func newApp() *cli.App { + cli.VersionPrinter = versionPrinter ctl := cli.NewApp() ctl.Name = "neo-go" ctl.Version = config.Version diff --git a/cli/main_test.go b/cli/main_test.go index 3c70662d0..427dc103f 100644 --- a/cli/main_test.go +++ b/cli/main_test.go @@ -7,6 +7,8 @@ import ( func TestCLIVersion(t *testing.T) { e := newExecutor(t, false) e.Run(t, "neo-go", "--version") - e.checkNextLine(t, "^neo-go version") + e.checkNextLine(t, "^NeoGo") + e.checkNextLine(t, "^Version:") + e.checkNextLine(t, "^GoVersion:") e.checkEOF(t) }