From 38912d85394604fe9cc238ef6eb9f6e75ceb38f9 Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Fri, 3 Sep 2021 18:13:49 -0500 Subject: Add config command to retrieve configuration values and clean command to clean build files --- cmd/planr/sub/build.go | 17 ++--------------- cmd/planr/sub/clean.go | 6 ++++-- cmd/planr/sub/config.go | 28 ++++++++++++++++++++++++++++ cmd/planr/sub/evaluate.go | 4 ++-- 4 files changed, 36 insertions(+), 19 deletions(-) create mode 100644 cmd/planr/sub/config.go (limited to 'cmd/planr/sub') diff --git a/cmd/planr/sub/build.go b/cmd/planr/sub/build.go index 142ef1c..4a1cda9 100644 --- a/cmd/planr/sub/build.go +++ b/cmd/planr/sub/build.go @@ -2,22 +2,9 @@ package sub import ( "golang.flu0r1ne.net/planr" - "golang.flu0r1ne.net/planr/adapters/gtest" - "os" ) -func Runner() planr.Runner { - r := planr.Runner {} - r.RegisterAdapter(>est.GtestAdapter{}) - - if wd, err := os.Getwd(); err == nil { - r.SetConfigDirFromTree(wd) - } - - return r -} - -func Build(params []string) { - Runner().Build() +func Build(runner planr.Runner, params []string) { + runner.Build() } diff --git a/cmd/planr/sub/clean.go b/cmd/planr/sub/clean.go index d40e967..d658c10 100644 --- a/cmd/planr/sub/clean.go +++ b/cmd/planr/sub/clean.go @@ -1,5 +1,7 @@ package sub -func Clean(params []string) { - Runner().Clean() +import "golang.flu0r1ne.net/planr" + +func Clean(runner planr.Runner, params []string) { + runner.Clean() } diff --git a/cmd/planr/sub/config.go b/cmd/planr/sub/config.go new file mode 100644 index 0000000..ee372c8 --- /dev/null +++ b/cmd/planr/sub/config.go @@ -0,0 +1,28 @@ +package sub + +import ( + "golang.flu0r1ne.net/planr" + "fmt" + "os" +) + + +func Config(runner planr.Runner, params []string) { + if len(params) != 1 { + fmt.Fprintf(os.Stderr, "Usage: planr config \n") + os.Exit(1) + } + + key := params[0] + + switch key { + case "builddir": + fmt.Printf("%s\n", runner.BuildDir()) + case "configdir": + fmt.Printf("%s\n", runner.ConfigDir()) + case "srcdir": + fmt.Printf("%s\n", runner.SrcDir()) + default: + fmt.Fprintf(os.Stderr, "\"%s\" not found in configuration\n", key) + } +} diff --git a/cmd/planr/sub/evaluate.go b/cmd/planr/sub/evaluate.go index d183b86..79d377e 100644 --- a/cmd/planr/sub/evaluate.go +++ b/cmd/planr/sub/evaluate.go @@ -4,8 +4,8 @@ import ( "golang.flu0r1ne.net/planr" ) -func Evaluate(params []string) { - tcs := Runner().Evaluate() +func Evaluate(runner planr.Runner, params []string) { + tcs := runner.Evaluate() earned := 0.0 total := 0.0 -- cgit v1.2.3