Skip to content

fix: allow overridding default string array #6873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! Cleanup code
  • Loading branch information
ammario committed Mar 29, 2023
commit 94b82a3005fd70edfeae3122f95ff5dde40b10f6
19 changes: 11 additions & 8 deletions cli/clibase/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,17 @@ func (s *OptionSet) SetDefaults(skip map[string]struct{}) error {
var merr *multierror.Error

for _, opt := range *s {
if opt.Name == "" {
merr = multierror.Append(
merr, xerrors.Errorf("parse: no Name field set"),
)
continue
}
if _, ok := skip[opt.Name]; ok {
continue
// Skip values that may have already been set by the user.
if len(skip) > 0 {
if opt.Name == "" {
merr = multierror.Append(
merr, xerrors.Errorf("parse: no Name field set"),
)
continue
}
if _, ok := skip[opt.Name]; ok {
continue
}
}

if opt.Default == "" {
Expand Down