예제 #1
0
func main() {
	flag.Parse()
	extra := flag.Args()

	if len(extra) != 1 {
		usage()
	}

	inputPath := filepath.ToSlash(extra[0])

	var outputPath string
	if outputPathFlag == nil || *outputPathFlag == "" {
		outputPath = extRe.ReplaceAllString(inputPath, "${1}_ffjson.go")
	} else {
		outputPath = *outputPathFlag
	}

	var goCmd string
	if goCmdFlag == nil || *goCmdFlag == "" {
		goCmd = "go"
	} else {
		goCmd = *goCmdFlag
	}

	err := generator.GenerateFiles(goCmd, inputPath, outputPath)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error: %s:\n\n", err)
		os.Exit(1)
	}

	println(outputPath)
}
예제 #2
0
파일: ffjson.go 프로젝트: rschmukler/ffjson
func main() {
	flag.Parse()
	extra := flag.Args()

	if len(extra) != 1 {
		usage()
	}

	inputPath := extra[0]
	var outputPath string
	if outputPathFlag == nil {
		outputPath = *outputPathFlag
	} else {
		outputPath = extRe.ReplaceAllString(inputPath, "${1}_ffjson.go")
	}

	err := generator.GenerateFiles(inputPath, outputPath)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error: %s:\n\n", err)
		os.Exit(1)
	}

	println(outputPath)
}