life-report/lifereport/report.go

41 lines
708 B
Go

package main
import (
"fmt"
"html/template"
"os"
"path"
report "github.com/thebaer/life-report"
)
func main() {
if len(os.Args) < 2 {
fmt.Print(`usage: lifereport [directory]
directory: path to a folder of reports
`)
return
}
dir := os.Args[1]
f, err := os.Open(path.Join(dir, "template.json"))
if err != nil {
fmt.Fprintf(os.Stdout, "Unable to open file: %v\n", err)
return
}
r, err := report.ParseReport(f)
if err != nil {
fmt.Fprintf(os.Stdout, "Unable to parse report: %v\n", err)
return
}
f.Close()
t, err := template.ParseFiles("../report.tmpl")
if err != nil {
fmt.Fprintf(os.Stdout, "Unable to parse template: %v\n", err)
return
}
t.Execute(os.Stdout, r)
}