Skip to content

Commit

Permalink
Copy() helper implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
gobwas committed Dec 17, 2020
1 parent 9c1f135 commit 6693975
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions flagutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,14 @@ func MergeInto(super *flag.FlagSet, setup func(*flag.FlagSet)) {
})
}

// Copy defines all flags from src with dst.
// It panics on any flag name collision.
func Copy(dst, src *flag.FlagSet) {
src.VisitAll(func(f *flag.Flag) {
dst.Var(f.Value, f.Name, f.Usage)
})
}

// CombineSets combines given sets into a third one.
// Every collided flags are combined into third one in a way that setting value
// to it sets value of both original flags.
Expand Down

0 comments on commit 6693975

Please sign in to comment.