Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
mkysel committed Dec 4, 2024
1 parent b90e1e7 commit 735afac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 9 additions & 4 deletions cmd/replication/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions pkg/config/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"errors"
"fmt"
"strings"
)

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 735afac

Please sign in to comment.