aboutsummaryrefslogtreecommitdiff
path: root/config.go
blob: d2d32e9795139cd86a69b34a3071b4eacddb685b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package planr

import (
  "github.com/BurntSushi/toml"
  "log"
  "path"
)

type planrConfig struct {
  Version string
  Project_title string
}

const PLANR_CONFIG = "config.toml"

func decodeConfig(configDir string) planrConfig {
  cfg := planrConfig { }

  configFile := path.Join(configDir, PLANR_CONFIG)

  if _, err := toml.DecodeFile(configFile, &cfg); err != nil {
    // TODO: handle missing config
    log.Fatalf("Could not decode global configuration %s: %v", configFile, err)
  }

  return cfg
}

func (cfg planrConfig) isIncompatibleWithVersion() bool {
  return cfg.Version > VERSION
}