Skip to content

Commit

Permalink
fix: running flag parsing more than 1 time
Browse files Browse the repository at this point in the history
  • Loading branch information
dsbasko committed Feb 16, 2024
1 parent 720135c commit dc18203
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions internal/flag/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ package flag
import (
"fmt"
"reflect"
"sync"

"github.com/integrii/flaggy"
)

var once sync.Once

// Read is a function that parses command-line flags into the provided cfg structure.
// The cfg parameter should be a pointer to a struct where each field represents a command-line flag.
// The function returns an error if the parsing process fails, wrapping the original error with a message.
Expand Down Expand Up @@ -89,9 +86,8 @@ func parseFlags(cfg any) error { //nolint:gocyclo
}

// The flaggy.Parse function is called only once to parse the command-line flags.
once.Do(func() {
flaggy.Parse()
})
flaggy.Parse()
flaggy.ResetParser()

return nil
}

0 comments on commit dc18203

Please sign in to comment.