Skip to content

Commit 757ea6c

Browse files
committed
feat: upgrade goNixArgParser
1 parent d6e7d5c commit 757ea6c

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/goNixArgParser/optionSet.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ func (s *OptionSet) Add(opt Option) error {
127127
}
128128
}
129129

130+
if !opt.AcceptValue && len(opt.DefaultValues) > 0 {
131+
opt.DefaultValues = nil
132+
}
133+
130134
option := &opt
131135

132136
// append
@@ -151,21 +155,23 @@ func (s *OptionSet) Add(opt Option) error {
151155
}
152156

153157
// redundant - env maps
154-
if len(option.EnvVars) > 0 {
155-
for _, envVar := range option.EnvVars {
156-
if len(envVar) == 0 {
157-
continue
158-
}
159-
envValue, hasEnv := os.LookupEnv(envVar)
160-
if !hasEnv {
161-
continue
162-
}
158+
for _, envVar := range option.EnvVars {
159+
if len(envVar) == 0 {
160+
continue
161+
}
162+
envValue, hasEnv := os.LookupEnv(envVar)
163+
if !hasEnv {
164+
continue
165+
}
163166

167+
if len(envValue) > 0 {
164168
if option.MultiValues {
165169
s.keyEnvMap[option.Key] = option.splitValues(envValue)
166170
} else {
167171
s.keyEnvMap[option.Key] = []string{envValue}
168172
}
173+
} else {
174+
s.keyEnvMap[option.Key] = []string{}
169175
}
170176
}
171177

0 commit comments

Comments
 (0)