From 1c3823b04e5d23586cb6ad87b76a1e3c8fe1dd04 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Sun, 24 Mar 2019 10:55:58 -0600 Subject: [PATCH] conf includes fields but needs testing --- config/config.go | 44 +++++++++++++++++++++++++++++++++++++++++--- config/new.go | 20 -------------------- 2 files changed, 41 insertions(+), 23 deletions(-) delete mode 100644 config/new.go diff --git a/config/config.go b/config/config.go index 142f56f..f29eb63 100644 --- a/config/config.go +++ b/config/config.go @@ -2,16 +2,25 @@ package config import ( "fmt" + "local/args" "sync" + "time" ) var config Config var lock = &sync.RWMutex{} type Config struct { - addr string - user string - pass string + addr string + user string + pass string + description string + category string + to string + from string + xferType string + cost float32 + date time.Time } func Values() Config { @@ -23,3 +32,32 @@ func Values() Config { func (c Config) String() string { return fmt.Sprintf("") } + +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") + as.Append(args.STRING, "description", "transaction description", "") + as.Append(args.STRING, "category", "transaction category", "Home: Grocery + Resturaunt") + as.Append(args.STRING, "to", "account receiving", "unknown") + as.Append(args.STRING, "from", "account sending", "chase") + as.Append(args.STRING, "type", "xfer/deposit/withdrawl", "withdrawl") + as.Append(args.FLOAT, "cost", "price of transaction", "0.00") + as.Append(args.TIME, "date", "date of transaction", "-0h") + 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() + config.description = as.Get("description").GetString() + config.category = as.Get("category").GetString() + config.to = as.Get("to").GetString() + config.from = as.Get("from").GetString() + config.xferType = as.Get("type").GetString() + config.cost = as.Get("cost").GetFloat() + config.date = as.Get("date").GetTime() + return nil +} diff --git a/config/new.go b/config/new.go deleted file mode 100644 index 5f11e69..0000000 --- a/config/new.go +++ /dev/null @@ -1,20 +0,0 @@ -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 -}