Skip to content

Commit

Permalink
add cli
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjit-bhat committed Jun 10, 2024
1 parent 9e561a6 commit 358c5c8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions rpc/cli.go
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)
}

0 comments on commit 358c5c8

Please sign in to comment.