Skip to content

Commit

Permalink
add flag to validate config and exit
Browse files Browse the repository at this point in the history
  • Loading branch information
capnspacehook committed Jan 22, 2022
1 parent a4c4e78 commit 52d4f02
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"os/signal"
Expand All @@ -15,12 +16,14 @@ var (
configPath string
debug bool
logPath string
testConfig bool
)

func init() {
flag.StringVar(&configPath, "c", "egress-eddie.toml", "path of the config file")
flag.BoolVar(&debug, "d", false, "enable debug logging")
flag.StringVar(&logPath, "l", "egress-eddie.log", "path to log to")
flag.BoolVar(&testConfig, "t", false, "validate the config and exit")
}

func main() {
Expand All @@ -41,6 +44,13 @@ func main() {
}

config, err := ParseConfig(configPath)
if testConfig {
if err != nil {
fmt.Fprintf(os.Stderr, "error parsing config: %v\n", err)
os.Exit(1)
}
os.Exit(0)
}
if err != nil {
logger.Fatal("error parsing config", zap.NamedError("error", err))
}
Expand Down

0 comments on commit 52d4f02

Please sign in to comment.