cli: change --version output format, fix #2611

This commit is contained in:
Roman Khimov 2022-07-27 16:28:40 +03:00
parent 1ff588a11b
commit eb67b61c0f
2 changed files with 13 additions and 1 deletions

View file

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

View file

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