Add -version flag (#1581)

Signed-off-by: Till Faelligen <tfaelligen@gmail.com>
main
S7evinK 2020-11-16 10:54:58 +01:00 committed by GitHub
parent b7e288084c
commit cb41c992f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -16,18 +16,28 @@ package setup
import ( import (
"flag" "flag"
"fmt"
"os"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/config" "github.com/matrix-org/dendrite/internal/config"
"github.com/sirupsen/logrus" "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. // ParseFlags parses the commandline flags and uses them to create a config.
func ParseFlags(monolith bool) *config.Dendrite { func ParseFlags(monolith bool) *config.Dendrite {
flag.Parse() flag.Parse()
if *version {
fmt.Println(internal.VersionString())
os.Exit(0)
}
if *configPath == "" { if *configPath == "" {
logrus.Fatal("--config must be supplied") logrus.Fatal("--config must be supplied")
} }