summaryrefslogtreecommitdiff
path: root/cmd/planr/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/planr/main.go')
-rw-r--r--cmd/planr/main.go51
1 files changed, 44 insertions, 7 deletions
diff --git a/cmd/planr/main.go b/cmd/planr/main.go
index 4b69a36..adcb50e 100644
--- a/cmd/planr/main.go
+++ b/cmd/planr/main.go
@@ -5,8 +5,11 @@ import (
"io"
"log"
"os"
+ "flag"
+ "golang.flu0r1ne.net/planr"
"golang.flu0r1ne.net/planr/cmd/planr/sub"
+ "golang.flu0r1ne.net/planr/adapters/gtest"
)
const (
@@ -20,7 +23,7 @@ func printUsage(w io.Writer) {
fmt.Fprintln(w, " build ")
fmt.Fprintln(w, " evaluate ")
fmt.Fprintln(w, " clean ")
-
+ fmt.Fprintln(w, " config ")
}
func dieUsage() {
@@ -28,6 +31,36 @@ func dieUsage() {
os.Exit(1)
}
+func NewRunner() planr.Runner {
+ r := planr.Runner {}
+
+ r.RegisterAdapter(&gtest.GtestAdapter{})
+
+ if wd, err := os.Getwd(); err == nil {
+ r.SetConfigDirFromTree(wd)
+ }
+
+ src := flag.String("srcdir", "", "source directory")
+ config := flag.String("configdir", "", "config directory")
+ build := flag.String("builddir", "", "build directory")
+
+ flag.Parse()
+
+ if src != nil && *src != "" {
+ r.SetSrcDir(*src)
+ }
+
+ if config != nil && *config != "" {
+ r.SetConfigDir(*config)
+ }
+
+ if build != nil && *build != "" {
+ r.SetBuildDir(*build)
+ }
+
+ return r
+}
+
func main() {
log.SetFlags(log.Llongfile | log.Lmsgprefix)
@@ -37,18 +70,22 @@ func main() {
dieUsage()
}
- subcommand := os.Args[1]
- subargs := os.Args[2:]
+ runner := NewRunner()
+
+ subcommand := flag.Arg(0)
+ subargs := flag.Args()[1:]
switch subcommand {
case "version":
fmt.Printf("%s\n", VERSION)
case "build":
- sub.Build(subargs)
- case "evaluate","eval":
- sub.Evaluate(subargs)
+ sub.Build(runner, subargs)
+ case "evaluate", "eval":
+ sub.Evaluate(runner, subargs)
case "clean":
- sub.Clean(subargs)
+ sub.Clean(runner, subargs)
+ case "config":
+ sub.Config(runner, subargs)
case "help", "-h", "-help", "--help":
printUsage(os.Stdout)
default: