Skip to content

Commit dec73b1

Browse files
authored
[Bugfix] Prevent Cobra Flags Duplication (#293)
1 parent 21da3bc commit dec73b1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

service/options/options.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ func (c ConfigurationPrefixes) Parse(args ...string) (*Configuration, []Configur
203203
var f []ConfigurationFlag
204204
config := NewConfiguration()
205205

206+
flags := map[string]bool{}
207+
206208
for _, arg := range args {
207209
arg = strings.SplitN(arg, "=", 2)[0]
208210

@@ -224,6 +226,12 @@ func (c ConfigurationPrefixes) Parse(args ...string) (*Configuration, []Configur
224226
return nil, nil, fmt.Errorf("option --%s is essential to the starters behavior and cannot be overwritten", targ)
225227
}
226228

229+
if _, ok := flags[arg]; ok {
230+
break
231+
} else {
232+
flags[arg] = true
233+
}
234+
227235
f = append(f, ConfigurationFlag{
228236
Key: arg,
229237
CleanKey: ckey,

0 commit comments

Comments
 (0)