Если не указан целевой файл - то вывод в stdout

Этот коммит содержится в:
Softonik 2022-11-19 21:42:54 +03:00 коммит произвёл Nikolay Kopitonenko
родитель 0cb0897021
коммит 5df60345e4

Просмотреть файл

@ -35,7 +35,7 @@ func getFlags() (int, string, string) {
}
func checkFlagsAreValid(source, target string) {
if source == "" || target == "" {
if source == "" {
printUsage()
os.Exit(1)
}
@ -58,12 +58,16 @@ func safeTranspile(mode int, source, target string) {
os.Exit(1)
}
defer in.Close()
// Create the Arduino sketch file.
os.Remove(target)
out, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR|os.O_SYNC, 0666)
if err != nil {
fmt.Fprintf(os.Stderr, "Arduino sketch file [%s] could not be opened! %v", target, err)
os.Exit(1)
out := os.Stdout
if target != "" {
// Create the Arduino sketch file.
os.Remove(target)
out, err = os.OpenFile(target, os.O_CREATE|os.O_RDWR|os.O_SYNC, 0666)
if err != nil {
fmt.Fprintf(os.Stderr, "Arduino sketch file [%s] could not be opened! %v", target, err)
os.Exit(1)
}
}
switch mode {
case CPP_MODE: