From 26b206b94c95904fd85b2a3e2c63d87c817afc32 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 3 Jun 2017 19:26:05 +0200 Subject: Move `Config` & `loadConfig()` to config.go Now that we have a 'config.go' file, it makes more sense for these two to live in that file. Change `loadConfig()` to return an error instead of printing it to the log. --- config.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'config.go') diff --git a/config.go b/config.go index f26e560..0aa76f1 100644 --- a/config.go +++ b/config.go @@ -5,9 +5,21 @@ import ( "os" "path/filepath" + "github.com/teddywing/timetasker/timetask" + + "github.com/BurntSushi/toml" "github.com/goulash/xdg" ) +type Config struct { + Auth struct { + Username string + PasswordCmd string `toml:"password_cmd"` + } + Profile timetask.Profile + Projects map[string]timetask.Project +} + const emptyConfig = `[auth] username = "" password_cmd = "" @@ -44,3 +56,13 @@ func MaybeWriteConfig() error { return nil } + +func loadConfig() error { + config = Config{} + _, err := toml.DecodeFile("config2.toml", &config) + if err != nil { + return err + } + + return nil +} -- cgit v1.2.3