q/src/cli/Main.go

30 lines
498 B
Go

package cli
import "os"
// Main is the entry point for the CLI frontend.
// It returns the exit code of the compiler.
// We never call os.Exit directly here because it's bad for testing.
func Main(args []string) int {
if len(args) == 0 {
return Help(os.Stderr, 2)
}
switch args[0] {
case "build":
return Build(args[1:])
case "run":
return Run(args[1:])
case "system":
return System(args[1:])
case "help":
return Help(os.Stdout, 0)
default:
return Help(os.Stderr, 2)
}
}