it panics but its there

master
Bel LaPointe 2019-03-23 15:39:34 -06:00
parent 041ecc2e7a
commit 598f027801
3 changed files with 54 additions and 0 deletions

25
config/config.go Normal file
View File

@ -0,0 +1,25 @@
package config
import (
"fmt"
"sync"
)
var config Config
var lock = &sync.RWMutex{}
type Config struct {
addr string
user string
pass string
}
func Values() Config {
lock.RLock()
defer lock.RUnlock()
return config
}
func (c Config) String() string {
return fmt.Sprintf("")
}

20
config/new.go Normal file
View File

@ -0,0 +1,20 @@
package config
import (
"local/args"
)
func New() error {
as := args.NewArgSet()
as.Append(args.STRING, "addr", "address to firefly iii", "192.168.0.86:9031")
as.Append(args.STRING, "u", "username", "squeaky2x3@blapointe.com")
as.Append(args.STRING, "p", "password", "fwees123")
if err := as.Parse(); err != nil {
return err
}
config = Config{}
config.user = as.Get("u").GetString()
config.pass = as.Get("p").GetString()
config.addr = as.Get("addr").GetString()
return nil
}

9
main.go Normal file
View File

@ -0,0 +1,9 @@
package main
import "local/fireflyiii/config"
func main() {
if err := config.New(); err != nil {
panic(err)
}
}