64 lines
1.7 KiB
Go
64 lines
1.7 KiB
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"local/args"
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
var config Config
|
|
var lock = &sync.RWMutex{}
|
|
|
|
type Config struct {
|
|
addr string
|
|
user string
|
|
pass string
|
|
description string
|
|
category string
|
|
to string
|
|
from string
|
|
xferType string
|
|
cost float32
|
|
date time.Time
|
|
}
|
|
|
|
func Values() Config {
|
|
lock.RLock()
|
|
defer lock.RUnlock()
|
|
return 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
|
|
}
|