func main() { opts := optparse.New("Usage: dynamodb-marshal file1.go [file2.go ...]", "dynamodb-marshal 0.0.1") force := opts.Bool([]string{"-f", "--force"}, "overwrite existing marshal files") os.Args[0] = "dynamodb-marshal" files := opts.Parse(os.Args) if len(files) == 0 { opts.PrintUsage() runtime.Exit(0) } log.AddConsoleLogger() for _, file := range files { path, err := filepath.Abs(file) if err != nil { runtime.StandardError(err) } parseFile(path, *force) } log.Wait() }
func main() { opts := optparse.Parser("Usage: genapi [options]", "0.1") root := opts.String( []string{"-r", "--root"}, "../src/espra", "path to the root package directory for the app", "PATH") ignoreList := opts.String( []string{"-i", "--ignore"}, "api.go html.go", "space-separated list of files/subdirectories to ignore", "LIST") digestFile := opts.String( []string{"-d", "--digest"}, "../etc/app/version.digest", "path to write the digest of the API version", "PATH") os.Args[0] = "genapi" opts.Parse(os.Args) log.AddConsoleLogger() ignore := strings.Split(*ignoreList, " ") for i, path := range ignore { ignore[i] = filepath.Join(*root, path) } pkgpath := strings.Split(*root, "/") pkgname := pkgpath[len(pkgpath)-1] if err := parseDirectory(pkgname, pkgname, *root, ignore); err != nil { runtime.StandardError(err) } for _, method := range methods { log.Info("%#v", method) } log.Wait() _ = *digestFile }
func Exit(code int) { log.Wait() RunExitHandlers() os.Exit(code) }
func main() { opts := optparse.Parser("Usage: html2domly [options]", "v") outputFile := opts.String([]string{"-o", "--output"}, "../coffee/templates.coffee", "coffeescript file to compile to", "PATH") templatesSrcDir := opts.String([]string{"-i", "--input"}, "../etc/domly", "template source directory", "PATH") printJSON := opts.Bool([]string{"--print"}, false, "Print the JSON nicely to the output logger") os.Args[0] = "html2domly" opts.Parse(os.Args) log.AddConsoleLogger() var ( data []byte err error prettyStr string basename string pretty bytes.Buffer ) dir, err := os.Open(*templatesSrcDir) if err != nil { runtime.StandardError(err) } defer dir.Close() out, err := os.Create(*outputFile) if err != nil { runtime.StandardError(err) } defer out.Close() names, err := dir.Readdirnames(0) if err != nil { runtime.StandardError(err) } out.Write([]byte("define 'templates', (exports, root) ->\n")) for _, name := range names { if strings.HasSuffix(name, ".html") { basename = strings.TrimSuffix(name, ".html") } else { log.Error("file %v does not end in .html", name) continue } templatePath := filepath.Join(*templatesSrcDir, name) data, err = ui.ParseTemplate(templatePath) if err != nil { log.StandardError(err) } else { err := json.Indent(&pretty, data, ">", " ") if err != nil { log.StandardError(err) log.Info("%v", data) } else if *printJSON { prettyStr = pretty.String() pretty.Reset() log.Info("%v", prettyStr) } out.Write([]byte(fmt.Sprintf(" exports['%s'] = `%s`\n", basename, data))) log.Info("compiled '%s'", name) } } out.Write([]byte(" return")) outPath, _ := filepath.Abs(*outputFile) log.Info("compiled domly written to: %v", outPath) log.Wait() }