From 9f575c37738eb273dbf89f37197c8880b80188e2 Mon Sep 17 00:00:00 2001 From: telyn Date: Fri, 23 Nov 2018 16:47:58 +0000 Subject: [PATCH] oh yeah actually include the ConcatFlags function --- cmd/bytemark/cliutil/concat_flags.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 cmd/bytemark/cliutil/concat_flags.go diff --git a/cmd/bytemark/cliutil/concat_flags.go b/cmd/bytemark/cliutil/concat_flags.go new file mode 100644 index 00000000..73baa690 --- /dev/null +++ b/cmd/bytemark/cliutil/concat_flags.go @@ -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 +}