From 39123a13be19dfef2ddf6c88dc78d625ed925ec0 Mon Sep 17 00:00:00 2001 From: Nikos Date: Tue, 3 Oct 2023 14:05:35 +0300 Subject: [PATCH] fix: add flag parsing logic --- cmd/main.go | 2 ++ internal/config/specs.go | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/cmd/main.go b/cmd/main.go index 9935f71a0..0164a47be 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -38,6 +38,8 @@ func main() { panic(fmt.Errorf("issues with environment sourcing: %s", err)) } + flags := config.NewFlags() + logger := logging.NewLogger(specs.LogLevel, specs.LogFile) logger.Debugf("env vars: %v", specs) diff --git a/internal/config/specs.go b/internal/config/specs.go index 8a4ef37a3..1ce14052e 100644 --- a/internal/config/specs.go +++ b/internal/config/specs.go @@ -1,5 +1,7 @@ package config +import "flag" + // EnvSpec is the basic environment configuration setup needed for the app to start type EnvSpec struct { OtelGRPCEndpoint string `envconfig:"otel_grpc_endpoint"` @@ -16,3 +18,16 @@ type EnvSpec struct { KratosPublicURL string `envconfig:"kratos_public_url"` HydraAdminURL string `envconfig:"hydra_admin_url"` } + +type Flags struct { + ShowVersion bool +} + +func NewFlags() *Flags { + f := new(Flags) + + flag.BoolVar(&f.ShowVersion, "version", false, "Show the app version") + flag.Parse() + + return f +}