Skip to content

Commit

Permalink
fix: make -skip-validation flag not depend on -validate flag being pr…
Browse files Browse the repository at this point in the history
…esent

right now `-skip-validation` is only considered if the -validate flag is
present; the name of the flag implies it being a boolean flag and it is
unintuitive that it needs another flag to be present referencing a
config file that will be ignored
  • Loading branch information
joanofxyz committed Apr 27, 2024
1 parent f1ff06e commit dd79715
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cmd/achcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ func main() {
}

func readValidationOpts(path string) *ach.ValidateOpts {
var opts ach.ValidateOpts

if *flagSkipValidation {
opts.SkipAll = true
return &opts
}

if path != "" {
// read config file
bs, readErr := os.ReadFile(path)
Expand All @@ -101,14 +108,10 @@ func readValidationOpts(path string) *ach.ValidateOpts {
os.Exit(1)
}

var opts ach.ValidateOpts
if err := json.Unmarshal(bs, &opts); err != nil {
fmt.Printf("ERROR: unmarshal of validate opts failed: %v\n", err)
os.Exit(1)
}
if *flagSkipValidation {
opts.SkipAll = true
}
return &opts
}
return nil
Expand Down

0 comments on commit dd79715

Please sign in to comment.