github.com/jgarto/itcv@v0.0.0-20180826224514-4eea09c1aa0d/cmd/coreGen/flag.go (about) 1 package main 2 3 import ( 4 "flag" 5 "fmt" 6 "os" 7 8 "myitcv.io/gogenerate" 9 ) 10 11 var ( 12 fLicenseFile = gogenerate.LicenseFileFlag() 13 fGoGenLog = gogenerate.LogFlag() 14 fCore = flag.Bool("core", false, "indicates we are generating for a core component (only do props expansion)") 15 fInit initFlag 16 ) 17 18 type initFlag struct { 19 val *string 20 } 21 22 func (f *initFlag) String() string { 23 return "(does not have a default value)" 24 } 25 26 func (f *initFlag) Set(s string) error { 27 f.val = &s 28 return nil 29 } 30 31 func init() { 32 flag.Var(&fInit, "init", "create a GopherJS React application using the specified template (see below)") 33 } 34 35 func usage() { 36 f := func(format string, args ...interface{}) { 37 fmt.Fprintf(os.Stderr, format, args...) 38 } 39 40 l := func(args ...interface{}) { 41 fmt.Fprintln(os.Stderr, args...) 42 } 43 44 l("Usage:") 45 f("\t%v [-init <template>]\n", os.Args[0]) 46 f("\t%v [-gglog <log_level>] [-licenseFile <filepath>] [-core]\n", os.Args[0]) 47 l() 48 49 flag.PrintDefaults() 50 }