From 75632a7d83eff41748c23c62e485d13ada5c2cd3 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Tue, 6 Jul 2021 16:24:18 +0300 Subject: [PATCH] [#667] node: Add `--version` flag support Signed-off-by: Pavel Karpy --- cmd/neofs-node/main.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cmd/neofs-node/main.go b/cmd/neofs-node/main.go index d311857f9..6ec40e43b 100644 --- a/cmd/neofs-node/main.go +++ b/cmd/neofs-node/main.go @@ -5,6 +5,7 @@ import ( "flag" "fmt" "log" + "os" "os/signal" "syscall" @@ -13,6 +14,11 @@ import ( "go.uber.org/zap" ) +const ( + // SuccessReturnCode returns when application closed without panic + SuccessReturnCode = 0 +) + // prints err to standard logger and calls os.Exit(1). func fatalOnErr(err error) { if err != nil { @@ -29,8 +35,20 @@ func fatalOnErrDetails(details string, err error) { func main() { configFile := flag.String("config", "", "path to config") + versionFlag := flag.Bool("version", false, "neofs-ir node version") flag.Parse() + if *versionFlag { + fmt.Printf( + "Version: %s \nBuild: %s \nDebug: %s\n", + misc.Version, + misc.Build, + misc.Debug, + ) + + os.Exit(SuccessReturnCode) + } + c := initCfg(*configFile) initApp(c)