read configuration file

This commit is contained in:
Xavier Henner
2019-07-08 22:32:12 +02:00
parent 9dc7d19811
commit dd38706b0b
30 changed files with 3621 additions and 24 deletions

View File

@@ -0,0 +1,38 @@
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"github.com/pyke369/golang-support/rpack"
)
func main() {
var (
options flag.FlagSet
usemain bool
)
options = flag.FlagSet{Usage: func() {
fmt.Fprintf(os.Stderr, "usage: %s [options] rootdir\n\noptions are:\n\n", filepath.Base(os.Args[0]))
options.PrintDefaults()
},
}
options.String("output", "static.go", "the generated output file path")
options.String("pkgname", "main", "the package name to use in the generated output")
options.String("funcname", "resources", "the function name to use in the generated output")
options.Bool("main", false, "whether to generate a main func or not")
if err := options.Parse(os.Args[1:]); err != nil {
os.Exit(1)
}
if options.NArg() == 0 {
options.Usage()
os.Exit(1)
}
if options.Lookup("main").Value.String() == "true" {
usemain = true
}
rpack.Pack(options.Arg(0), options.Lookup("output").Value.String(), options.Lookup("pkgname").Value.String(), options.Lookup("funcname").Value.String(), usemain)
}