Created
October 24, 2018 01:48
-
-
Save kwilczynski/cd500a887f8a5b95ca2ae52368525452 to your computer and use it in GitHub Desktop.
Kingpin multiple filters
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"github.com/davecgh/go-spew/spew" | |
"gopkg.in/alecthomas/kingpin.v2" | |
) | |
type Config struct { | |
filters ec2Filters | |
} | |
type filters []string | |
func (t *filters) Set(value string) error { | |
*t = append(*t, value) | |
return nil | |
} | |
func (t *filters) IsCumulative() bool { | |
return true | |
} | |
func (t *filters) String() string { | |
return fmt.Sprint([]string(*t)) | |
} | |
func (t *filters) Type() string { | |
return "" | |
} | |
func Filters(s Settings) (filters *[]string) { | |
filters = make([]string, 0) | |
s.SetValue((*ifilters)(filters)) | |
return | |
} | |
func main() { | |
cfg := &Config{ | |
filters: Filters(kingpin.Arg("filters", "A set of filters.")) | |
} | |
kingpin.UsageTemplate(kingpin.CompactUsageTemplate) | |
kingpin.Parse() | |
spew.Dump(cfg) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment