diff --git a/cmd/replication/main.go b/cmd/replication/main.go index f1ffa4df..685a24d0 100644 --- a/cmd/replication/main.go +++ b/cmd/replication/main.go @@ -25,16 +25,21 @@ var options config.ServerOptions func main() { _, err := flags.Parse(&options) + if err != nil { + if err, ok := err.(*flags.Error); !ok || err.Type != flags.ErrHelp { + fatal("Could not parse options: %s", err) + } + return + } + if options.Version { fmt.Printf("Version: %s\n", Commit) return } + err = config.ValidateServerOptions(options) if err != nil { - if err, ok := err.(*flags.Error); !ok || err.Type != flags.ErrHelp { - fatal("Could not parse options: %s", err) - } - return + fatal("Could not validate options: %s", err) } logger, _, err := utils.BuildLogger(options.Log) diff --git a/pkg/config/validation.go b/pkg/config/validation.go index e7dccef0..9cb0b9e3 100644 --- a/pkg/config/validation.go +++ b/pkg/config/validation.go @@ -2,6 +2,7 @@ package config import ( "errors" + "fmt" "strings" ) @@ -69,11 +70,13 @@ func ValidateServerOptions(options ServerOptions) error { if len(missingSet) > 0 { var errorMessages []string - errorMessages = append(errorMessages, "Missing required arguments:") for err := range missingSet { errorMessages = append(errorMessages, err) } - errs = append(errs, strings.Join(errorMessages, ", ")) + errs = append( + errs, + fmt.Sprintf("Missing required arguments: %s", strings.Join(errorMessages, ", ")), + ) } if len(customSet) > 0 { for err := range customSet {