Skip to content

Commit

Permalink
fix: add flag parsing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nsklikas committed Oct 3, 2023
1 parent 272dcd5 commit 39123a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions internal/config/specs.go
Original file line number Diff line number Diff line change
@@ -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"`
Expand All @@ -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
}

0 comments on commit 39123a1

Please sign in to comment.