conf includes fields but needs testing
parent
598f027801
commit
1c3823b04e
|
|
@ -2,16 +2,25 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"local/args"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var config Config
|
var config Config
|
||||||
var lock = &sync.RWMutex{}
|
var lock = &sync.RWMutex{}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
addr string
|
addr string
|
||||||
user string
|
user string
|
||||||
pass string
|
pass string
|
||||||
|
description string
|
||||||
|
category string
|
||||||
|
to string
|
||||||
|
from string
|
||||||
|
xferType string
|
||||||
|
cost float32
|
||||||
|
date time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func Values() Config {
|
func Values() Config {
|
||||||
|
|
@ -23,3 +32,32 @@ func Values() Config {
|
||||||
func (c Config) String() string {
|
func (c Config) String() string {
|
||||||
return fmt.Sprintf("")
|
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
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue