From 78bca82e204fd23b1c7b93d7bd091a35ab814e38 Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Fri, 13 Nov 2020 21:38:27 +0100 Subject: [PATCH] Add -version flag Signed-off-by: Till Faelligen --- internal/setup/flags.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/setup/flags.go b/internal/setup/flags.go index e4fc58d60..c6ecb5cd1 100644 --- a/internal/setup/flags.go +++ b/internal/setup/flags.go @@ -16,18 +16,28 @@ package setup import ( "flag" + "fmt" + "os" + "github.com/matrix-org/dendrite/internal" "github.com/matrix-org/dendrite/internal/config" - "github.com/sirupsen/logrus" ) -var configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.") +var ( + configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.") + version = flag.Bool("version", false, "Shows the current version and exits immediately.") +) // ParseFlags parses the commandline flags and uses them to create a config. func ParseFlags(monolith bool) *config.Dendrite { flag.Parse() + if *version { + fmt.Println(internal.VersionString()) + os.Exit(0) + } + if *configPath == "" { logrus.Fatal("--config must be supplied") }