-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e561a6
commit 358c5c8
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
"os" | ||
"strings" | ||
) | ||
|
||
var in = flag.String("in", "", "required path to input file") | ||
var out = flag.String("out", "", "optional path to output file") | ||
|
||
func main() { | ||
log.SetFlags(log.Lshortfile) | ||
flag.Parse() | ||
if *in == "" { | ||
log.Panic("empty input file. maybe there was no input arg?") | ||
} | ||
res := compile(*in) | ||
if *out == "" { | ||
*out = strings.Replace(*in, ".go", ".out.go", 1) | ||
} | ||
if err := os.WriteFile(*out, res, 0644); err != nil { | ||
log.Panic("failed to write to output file: ", *out) | ||
} | ||
log.Print("wrote to output file: ", *out) | ||
} |