aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.go22
-rw-r--r--main.go18
2 files changed, 22 insertions, 18 deletions
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
+}
diff --git a/main.go b/main.go
index 1d90f94..5eae47f 100644
--- a/main.go
+++ b/main.go
@@ -9,21 +9,11 @@ import (
"github.com/teddywing/timetasker/timetask"
- "github.com/BurntSushi/toml"
"gopkg.in/alecthomas/kingpin.v2"
)
var VERSION string = "0.1.0"
-type Config struct {
- Auth struct {
- Username string
- PasswordCmd string `toml:"password_cmd"`
- }
- Profile timetask.Profile
- Projects map[string]timetask.Project
-}
-
var config Config
func main() {
@@ -110,11 +100,3 @@ func main() {
body, err = ioutil.ReadAll(resp.Body)
log.Println(string(body))
}
-
-func loadConfig() {
- config = Config{}
- _, err := toml.DecodeFile("config2.toml", &config)
- if err != nil {
- log.Println(err)
- }
-}