diff --git a/cmd/go-tr/main.go b/cmd/go-tr/main.go index 19b1f67..ebc93fb 100644 --- a/cmd/go-tr/main.go +++ b/cmd/go-tr/main.go @@ -19,6 +19,21 @@ func main() { safeTranspile(mode, source, target) } +func getFlags() (int, string, string) { + pmode := flag.Bool("p", false, "Mode: C++ or Python") + flag.Parse() + + source := flag.Arg(0) + target := flag.Arg(1) + + mode := CPP_MODE + if *pmode { + mode = PYTHON_MODE + } + + return mode, source, target +} + func checkFlagsAreValid(source, target string) { if source == "" || target == "" { printUsage() @@ -26,26 +41,9 @@ func checkFlagsAreValid(source, target string) { } } -func getFlags() (int, string, string) { - // source := flag.String("source", "", "Golang source file") - // target := flag.String("target", "", "Arduino sketch file") - flag.Parse() - mode := CPP_MODE - source := flag.Arg(0) - target := flag.Arg(1) - - if source == "-p" { - mode = PYTHON_MODE - source = flag.Arg(1) - target = flag.Arg(2) - } - - return mode, source, target -} - func printUsage() { fmt.Print("This program transpiles Golang source into corresponding C++/python code.\n\n") - fmt.Printf("Options:\n by default C++ mode\n -p - python mode\n") + fmt.Printf("Options:\n") flag.PrintDefaults() fmt.Print("\n") fmt.Print("Example:\n")