From 0ea2e92b7a16e736fc72019891ce3f0e3bfb6bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Raddaoui=20Mar=C3=ADn?= Date: Tue, 21 May 2024 19:41:37 +0200 Subject: [PATCH] Add version flag to worker command [skip-codecov] --- cmd/worker/main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/worker/main.go b/cmd/worker/main.go index fa3d151d..902fb2d8 100644 --- a/cmd/worker/main.go +++ b/cmd/worker/main.go @@ -16,9 +16,12 @@ import ( "github.com/artefactual-sdps/preprocessing-sfa/internal/version" ) +const appName = "preprocessing-sfa-worker" + func main() { p := pflag.NewFlagSet(workercmd.Name, pflag.ExitOnError) p.String("config", "", "Configuration file") + p.Bool("version", false, "Show version information") if err := p.Parse(os.Args[1:]); err == flag.ErrHelp { os.Exit(1) } else if err != nil { @@ -26,6 +29,11 @@ func main() { os.Exit(1) } + if v, _ := p.GetBool("version"); v { + fmt.Println(version.Info(appName)) + os.Exit(0) + } + var cfg config.Configuration configFile, _ := p.GetString("config") configFileFound, configFileUsed, err := config.Read(&cfg, configFile)