github.com/dawnbass68/maddcash@v0.0.0-20201001105353-c91c12cb36e5/build/templates/generate.go (about) 1 package main 2 3 import ( 4 "blockbook/build/tools" 5 "fmt" 6 "os" 7 "path/filepath" 8 "strings" 9 ) 10 11 const ( 12 configsDir = "configs" 13 templateDir = "build/templates" 14 outputDir = "build/pkg-defs" 15 ) 16 17 func main() { 18 if len(os.Args) < 2 { 19 var coins []string 20 filepath.Walk(filepath.Join(configsDir, "coins"), func(path string, info os.FileInfo, err error) error { 21 n := strings.TrimSuffix(info.Name(), ".json") 22 if n != info.Name() { 23 coins = append(coins, n) 24 } 25 return nil 26 }) 27 fmt.Fprintf(os.Stderr, "Usage: %s coin\nCoin is one of:\n%v\n", filepath.Base(os.Args[0]), coins) 28 os.Exit(1) 29 } 30 31 coin := os.Args[1] 32 config, err := build.LoadConfig(configsDir, coin) 33 if err == nil { 34 err = build.GeneratePackageDefinitions(config, templateDir, outputDir) 35 } 36 if err != nil { 37 panic(err) 38 } 39 fmt.Printf("Package files for %v generated to %v\n", coin, outputDir) 40 }