[#667] node: Add --version flag support

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-07-06 16:24:18 +03:00 committed by Leonard Lyubich
parent eadc3a4de9
commit 75632a7d83

View file

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