github.com/jgarto/itcv@v0.0.0-20180826224514-4eea09c1aa0d/cmd/reactGen/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 fInit initFlag 15 ) 16 17 type initFlag struct { 18 val *string 19 } 20 21 func (f *initFlag) String() string { 22 return "(does not have a default value)" 23 } 24 25 func (f *initFlag) Set(s string) error { 26 f.val = &s 27 return nil 28 } 29 30 func init() { 31 flag.Var(&fInit, "init", "create a GopherJS React application using the specified template (see below)") 32 } 33 34 func usage() { 35 f := func(format string, args ...interface{}) { 36 fmt.Fprintf(os.Stderr, format, args...) 37 } 38 39 l := func(args ...interface{}) { 40 fmt.Fprintln(os.Stderr, args...) 41 } 42 43 l("Usage:") 44 f("\t%v [-init <template>]\n", os.Args[0]) 45 f("\t%v [-gglog <log_level>] [-licenseFile <filepath>] [-core]\n", os.Args[0]) 46 l() 47 48 flag.PrintDefaults() 49 50 l() 51 l("The flag -init is very basic and only understands two value for now: minimal or ") 52 l("bootstrap. Both give you a minimal Gopher React application, the latter applies ") 53 l("a basic Bootstrap (http://getbootstrap.com/) template.") 54 l() 55 l("When -init is not specified, it is assumed that reactGen is being called indirectly") 56 l("via go generate. The options for -gglog and -licenseFile would therefore be set in") 57 l("via the //go:generate directives. See https://blog.golang.org/generate for more details.") 58 }