Skip to content
Draft
Changes from all commits
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
13 changes: 13 additions & 0 deletions flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,19 @@ func (f *FlagSet) AddFlagSet(newSet *FlagSet) {
})
}

// AddParentFlagSet adds parent FlagSet to f. If a flag and shorthand is already present in f
// the flag from parentSet will be ignored.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs unit testing

func (f *FlagSet) AddParentFlagSet(parentSet *FlagSet) {
if parentSet == nil {
return
}
parentSet.VisitAll(func(flag *Flag) {
if f.Lookup(flag.Name) == nil && f.ShorthandLookup(flag.Shorthand) == nil {
f.AddFlag(flag)
}
})
}

// Var defines a flag with the specified name and usage string. The type and
// value of the flag are represented by the first argument, of type Value, which
// typically holds a user-defined implementation of Value. For instance, the
Expand Down