-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
oh yeah actually include the ConcatFlags function
- Loading branch information
telyn
committed
Nov 23, 2018
1 parent
eb16408
commit 9f575c3
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |