conf includes fields but needs testing

master
Bel LaPointe 2019-03-24 10:55:58 -06:00
parent 598f027801
commit 1c3823b04e
2 changed files with 41 additions and 23 deletions

View File

@ -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
}

View File

@ -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
}