Skip to content

Commit

Permalink
show proper error message if ledger is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
ananthakumaran committed Apr 20, 2022
1 parent d3f9160 commit 5a58b5a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/csv"

"log"
log "github.com/sirupsen/logrus"
"os/exec"
"strconv"
"time"
Expand All @@ -15,11 +15,16 @@ import (
func Parse(journalPath string) ([]*posting.Posting, error) {
var postings []*posting.Posting

_, err := exec.LookPath("ledger")
if err != nil {
log.Fatal(err)
}

command := exec.Command("ledger", "-f", journalPath, "csv", "--csv-format", "%(quoted(date)),%(quoted(payee)),%(quoted(display_account)),%(quoted(commodity(scrub(display_amount)))),%(quoted(quantity(scrub(display_amount)))),%(quoted(to_int(scrub(market(amount,date)))))\n")
var output, error bytes.Buffer
command.Stdout = &output
command.Stderr = &error
err := command.Run()
err = command.Run()
if err != nil {
log.Fatal(error.String())
return nil, err
Expand Down

0 comments on commit 5a58b5a

Please sign in to comment.