Skip to content

Commit

Permalink
Merge pull request #14 from sstarcher/master
Browse files Browse the repository at this point in the history
Render errors to stderr
  • Loading branch information
arschles committed Apr 24, 2016
2 parents 17bca53 + f55f4a5 commit c0e37be
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ func main() {
in := flag.String("in", "", "the template to render")
flag.Parse()
if *in == "" {
fmt.Println("Error: the input file was empty")
fmt.Fprintln(os.Stderr, "Error: the input file was empty")
flag.Usage()
os.Exit(1)
}

tpl, err := template.ParseFiles(*in)
if err != nil {
fmt.Printf("Error: parsing template %s (%s)\n", *in, err)
fmt.Fprintf(os.Stderr, "Error: parsing template %s (%s)\n", *in, err)
os.Exit(1)
}

envMap := collectEnv()

if err := tpl.Funcs(sprig.TxtFuncMap()).Execute(os.Stdout, envMap); err != nil {
fmt.Printf("Rendering template (%s)", err)
fmt.Fprintf(os.Stderr, "Rendering template (%s)", err)
os.Exit(1)
}
}

0 comments on commit c0e37be

Please sign in to comment.