Skip to content

Commit

Permalink
oh yeah actually include the ConcatFlags function
Browse files Browse the repository at this point in the history
  • Loading branch information
telyn committed Nov 23, 2018
1 parent eb16408 commit 9f575c3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cmd/bytemark/cliutil/concat_flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cliutil

import (
"github.com/urfave/cli"
)

// ConcatFlags combines multiple slices of flags together without modification
func ConcatFlags(flagSets ...[]cli.Flag) (res []cli.Flag) {
// saves us re-allocating each time.. Probably doesn't save a lot of
// memory/GC time in real life but eh. Feels good to be efficient.
totalLen := 0
for i := range flagSets {
totalLen += len(flagSets[i])
}
res = make([]cli.Flag, 0, totalLen)

for i := range flagSets {
res = append(res, flagSets[i]...)
}
return
}

0 comments on commit 9f575c3

Please sign in to comment.