diff --git a/cmd/go-tr/main.go b/cmd/go-tr/main.go index 47e6416..fef9767 100644 --- a/cmd/go-tr/main.go +++ b/cmd/go-tr/main.go @@ -15,25 +15,27 @@ func main() { func checkFlagsAreValid(source, target string) { if source == "" || target == "" { - flag.Usage() + printUsage() os.Exit(1) } } func getFlags() (string, string) { - source := flag.String("source", "", "Golang source file") - target := flag.String("target", "", "Arduino sketch file") + // source := flag.String("source", "", "Golang source file") + // target := flag.String("target", "", "Arduino sketch file") flag.Parse() - return *source, *target + source := flag.Arg(0) + target := flag.Arg(1) + return source, target } func printUsage() { - fmt.Print("This program transpiles Golang source into corresponding Arduino sketches.\n\n") + fmt.Print("This program transpiles Golang source into corresponding C code.\n\n") fmt.Print("Options:\n") flag.PrintDefaults() fmt.Print("\n") fmt.Print("Example:\n") - fmt.Printf("\tesp32 -source impl/blink/controller.go -target impl/blink/controller.transpile\n\n") + fmt.Printf("\tgo-tr controller.go controller.ino\n\n") } func safeTranspile(source, target string) {