diff options
| author | Nikolaus Gotsche <n@softwarefools.com> | 2018-09-12 02:37:44 +0200 |
|---|---|---|
| committer | Nikolaus Gotsche <n@softwarefools.com> | 2018-09-12 02:37:44 +0200 |
| commit | 06c06f5f6427f6da22b2476fa208e8c4ce54b7ee (patch) | |
| tree | b1ecc69ccc3ca6e915b6f4084598b530fbf24d04 /config.go | |
| parent | fd4a4409ee8e6b772db30611e968778b68eca0d6 (diff) | |
Conf/DB into Home Dir, general beautification and debug
Diffstat (limited to 'config.go')
| -rw-r--r-- | config.go | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -6,7 +6,9 @@ import ( //"os" "io/ioutil" //"strconv" + "github.com/fatih/color" "github.com/BurntSushi/toml" + "github.com/atrox/homedir" ) type Config struct { @@ -32,7 +34,8 @@ var conffile string var config Config func init() { - conffile = "laboravi.config.toml" + conffile,err = homedir.Expand("~/.laboravi.config.toml") //make ~ when finished + checkErr(err) } func editConf() { @@ -57,13 +60,16 @@ func editConf() { } func initConf() { + boldGreen := color.New(color.FgGreen, color.Bold).SprintFunc() + boldRed := color.New(color.FgRed, color.Bold).SprintFunc() for { if _, err := toml.DecodeFile(conffile, &config); err != nil { //fmt.Println(err) - fmt.Println("Configuration file not found") + fmt.Println(boldRed("Configuration file not found")) makeNewTOML(false) }else{ - fmt.Println("Configuration loaded Successfully") + //fmt.Println(boldGreen("Configuration loaded Successfully")) + fmt.Println("Config loaded...",boldGreen("Hello ",config.Name)) break } } @@ -76,7 +82,9 @@ func makeNewTOML(gibts bool) { fmt.Println("Making new Configuration File") //Examplenames Coming soon n := "" - config = Config{".mytimes.db",n,n,n,n,n,n,n,n,n,n,n,n,n,n,n} + file,err := homedir.Expand("~/.mywork.db") + checkErr(err) + config = Config{file,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n} } //fmt.Println("Whats Your Namecount\n") database := getNewInput("DB File Path: ",config.Database) |
