From 0bfcd7a8a9441e1a8c7e1d75fe3150624419728f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20=C3=85hall?= Date: Tue, 23 Apr 2024 20:21:08 +0200 Subject: [PATCH] Flag version, bumped to v2 --- flag.go | 7 +++++++ main.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/flag.go b/flag.go index acbc6ac..1689d95 100644 --- a/flag.go +++ b/flag.go @@ -19,17 +19,24 @@ func (i *arrayFlags) Set(value string) error { } var ( + flagVersion bool flagIncludeAll bool flagExcludeAll bool flagExcept arrayFlags ) func init() { + flag.BoolVar(&flagVersion, "version", false, "Prints version and exits.") flag.BoolVar(&flagIncludeAll, "include-all", false, "Split out all databases, with provided exceptions.") flag.BoolVar(&flagExcludeAll, "exclude-all", false, "Split out no databases, with provided exceptions.") flag.Var(&flagExcept, "except", "Exception to rule, can be used multiple times") flag.Parse() + if flagVersion { + fmt.Println(VERSION) + os.Exit(0) + } + if flagIncludeAll && flagExcludeAll { fmt.Println("-include-all and -exclude-all are mutually exclusive") os.Exit(1) diff --git a/main.go b/main.go index b383e34..929bbc1 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,7 @@ import ( "slices" ) -const VERSION = "v1" +const VERSION = "v2" const MAXLINE = 1048576 type Db struct {