Skip to content

Commit 94b82a3

Browse files
committed
fixup! Cleanup code
1 parent 6b7bb4e commit 94b82a3

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

cli/clibase/option.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,17 @@ func (s *OptionSet) SetDefaults(skip map[string]struct{}) error {
156156
var merr *multierror.Error
157157

158158
for _, opt := range *s {
159-
if opt.Name == "" {
160-
merr = multierror.Append(
161-
merr, xerrors.Errorf("parse: no Name field set"),
162-
)
163-
continue
164-
}
165-
if _, ok := skip[opt.Name]; ok {
166-
continue
159+
// Skip values that may have already been set by the user.
160+
if len(skip) > 0 {
161+
if opt.Name == "" {
162+
merr = multierror.Append(
163+
merr, xerrors.Errorf("parse: no Name field set"),
164+
)
165+
continue
166+
}
167+
if _, ok := skip[opt.Name]; ok {
168+
continue
169+
}
167170
}
168171

169172
if opt.Default == "" {

0 commit comments

Comments
 (0)