github.com/benma/gogen@v0.0.0-20160826115606-cf49914b915a/cmd/gospecific/main.go (about)

     1  package main
     2  
     3  import (
     4  	"flag"
     5  	"log"
     6  
     7  	"github.com/ernesto-jimenez/gogen/specific"
     8  )
     9  
    10  var (
    11  	pkg          = flag.String("pkg", "", "generic package")
    12  	out          = flag.String("out-dir", "", "directory to store the specific package")
    13  	specificType = flag.String("specific-type", "", "what specific type to use instead of interface{}")
    14  	skipTests    = flag.Bool("skip-tests", false, "whether to skip generating test files")
    15  )
    16  
    17  func main() {
    18  	flag.Parse()
    19  
    20  	if *pkg == "" {
    21  		flag.Usage()
    22  		log.Fatal("missing generic package")
    23  	}
    24  
    25  	if *specificType == "" {
    26  		flag.Usage()
    27  		log.Fatal("missing specific type")
    28  	}
    29  
    30  	if err := specific.Process(*pkg, *out, *specificType, func(opts *specific.Options) {
    31  		opts.SkipTestFiles = *skipTests
    32  	}); err != nil {
    33  		log.Fatal(err)
    34  	}
    35  }