mirror of
https://github.com/danog/gllvm.git
synced 2024-11-30 06:39:06 +01:00
41 lines
835 B
Go
41 lines
835 B
Go
package main
|
|
|
|
import(
|
|
"os"
|
|
"os/exec"
|
|
"log"
|
|
)
|
|
|
|
func main() {
|
|
// Parse command line
|
|
var args = os.Args
|
|
if len(args) < 2 {
|
|
log.Fatal("Not enough arguments.")
|
|
}
|
|
var modeFlag = args[1]
|
|
args = args[2:]
|
|
|
|
switch modeFlag {
|
|
case "compile":
|
|
// Call main compiling function with args
|
|
compile(args)
|
|
case "extract":
|
|
// Call main extracting function with args
|
|
extract(args)
|
|
default:
|
|
log.Fatal("You should call gowllvm with a valid mode.")
|
|
}
|
|
}
|
|
|
|
// Executes a command then returns true if there was an error
|
|
func execCmd(cmdExecName string, args []string) bool {
|
|
cmd := exec.Command(cmdExecName, args...)
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stderr = os.Stderr
|
|
if cmd.Run() == nil {
|
|
return false
|
|
} else {
|
|
return true
|
|
}
|
|
}
|