Merge pull request #2 from jonafato/configurable-ledger-binary
Add ledger binary command line flag
This commit is contained in:
7
main.go
7
main.go
@@ -13,11 +13,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
ledgerBinary := flag.String("b", "ledger", "Ledger Binary")
|
||||||
ledgerFile := flag.String("f", "ledger.ledger", "Ledger File")
|
ledgerFile := flag.String("f", "ledger.ledger", "Ledger File")
|
||||||
priceDbFile := flag.String("p", "prices.db", "Price Database File")
|
priceDbFile := flag.String("p", "prices.db", "Price Database File")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
commodities := GetCommodities(*ledgerFile)
|
commodities := GetCommodities(*ledgerFile, *ledgerBinary)
|
||||||
|
|
||||||
pricedb, err := os.OpenFile(*priceDbFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
pricedb, err := os.OpenFile(*priceDbFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -62,8 +63,8 @@ func GetTimeString() string {
|
|||||||
return time.Now().Format("2006-01-02 15:04:05")
|
return time.Now().Format("2006-01-02 15:04:05")
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCommodities(ledger string) []string {
|
func GetCommodities(ledger string, binary string) []string {
|
||||||
cmd := exec.Command("ledger", "-f", ledger, "commodities")
|
cmd := exec.Command(binary, "-f", ledger, "commodities")
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Ledger file commodity report failed with %s\n", err)
|
log.Fatalf("Ledger file commodity report failed with %s\n", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user