package main import ( "flag" "fmt" "git.e3t.cc/e3team/pancheri" "gopkg.in/yaml.v2" "os" ) func main() { zonePath := flag.String("zone", "", "Zone file to render") printUsage := flag.Bool("help", false, "Print command line usage") renderFormat := flag.String("format", "bind", "Format to render to (bind/pancheri)") flag.Parse() if *printUsage { flag.Usage() os.Exit(0) } zone, err := pancheri.LoadZone(*zonePath) if err != nil { fmt.Printf("error loading zone: %s\n", err) os.Exit(1) } if *renderFormat == "pancheri" { msh, err := yaml.Marshal(zone) if err != nil { fmt.Printf("error saving zone: %s\n", err) os.Exit(1) } fmt.Println(string(msh[:])) } else if *renderFormat == "bind" { println(zone.RenderZone()) } else { fmt.Printf("unrecognized render format: %s", *renderFormat) } }