summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/planr/sub/build.go2
-rw-r--r--cmd/planr/sub/common.go4
-rw-r--r--cmd/planr/sub/evaluate.go2
-rw-r--r--config.go15
4 files changed, 15 insertions, 8 deletions
diff --git a/cmd/planr/sub/build.go b/cmd/planr/sub/build.go
index 48edd9c..e93e0cb 100644
--- a/cmd/planr/sub/build.go
+++ b/cmd/planr/sub/build.go
@@ -4,7 +4,7 @@ import (
"golang.flu0r1ne.net/planr"
)
-func Build(runner planr.Runner, params []string, cfg planr.Config) {
+func Build(runner planr.Runner, params []string, cfg * planr.Config) {
dieIncompatibleVersion(cfg)
tcs := runner.CollectCases()
runner.Build(tcs)
diff --git a/cmd/planr/sub/common.go b/cmd/planr/sub/common.go
index 67d07f8..9126f3c 100644
--- a/cmd/planr/sub/common.go
+++ b/cmd/planr/sub/common.go
@@ -6,8 +6,8 @@ import (
"fmt"
)
-func dieIncompatibleVersion(cfg planr.Config) {
- if cfg.IncompatibleWithVersion() {
+func dieIncompatibleVersion(cfg *planr.Config) {
+ if cfg != nil && cfg.IncompatibleWithVersion() {
fmt.Fprintf(os.Stderr, "This version of PlanR (%v) is incompatible with config version %s\n", planr.VERSION, cfg.Version)
fmt.Fprintf(os.Stderr, "Please upgrade to version %s or greater\n", cfg.Version)
os.Exit(1)
diff --git a/cmd/planr/sub/evaluate.go b/cmd/planr/sub/evaluate.go
index 21481a1..30d30d2 100644
--- a/cmd/planr/sub/evaluate.go
+++ b/cmd/planr/sub/evaluate.go
@@ -34,7 +34,7 @@ func jsonPrint(results gradingResults) {
fmt.Println(string(res))
}
-func Evaluate(runner planr.Runner, params []string, cfg planr.Config) {
+func Evaluate(runner planr.Runner, params []string, cfg *planr.Config) {
f := flag.NewFlagSet("evaluate", flag.ExitOnError)
jsonOutput := f.Bool("json", false, "print json output")
diff --git a/config.go b/config.go
index 88495e3..d7cd3e4 100644
--- a/config.go
+++ b/config.go
@@ -13,14 +13,21 @@ type Config struct {
const PLANR_CONFIG_FILE = "config.toml"
-func DecodeConfig(configDir string) Config {
- cfg := Config { }
+// TODO: REMOVE
+const STRICTLY_REQUIRE_CONFIG = false
+
+func DecodeConfig(configDir string) *Config {
+ cfg := new(Config)
configFile := path.Join(configDir, PLANR_CONFIG_FILE)
- if _, err := toml.DecodeFile(configFile, &cfg); err != nil {
+ if _, err := toml.DecodeFile(configFile, cfg); err != nil {
+ cfg = nil
+
// TODO: handle missing config
- log.Fatalf("Could not decode global configuration %s: %v", configFile, err)
+ if STRICTLY_REQUIRE_CONFIG {
+ log.Fatalf("Could not decode global configuration %s: %v", configFile, err)
+ }
}
return cfg