Skip to content

Commit

Permalink
make error printing look nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
atomicptr committed Jul 24, 2024
1 parent fcfc9e1 commit eea0539
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion cmd/tmplr/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package main

import (
"fmt"

"github.com/atomicptr/tmplr/pkg/cli"
"github.com/charmbracelet/lipgloss"
)

func main() {
err := cli.Run()
if err != nil {
panic(err)
style := lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("#FF0000"))
fmt.Println(style.Render("[ERROR]"), err)
}
}
7 changes: 6 additions & 1 deletion pkg/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ func Run() error {
if err != nil {
return err
}
f.Close()
defer (func() {
err := f.Close()
if err != nil {
panic(err)
}
})()
continue
}

Expand Down

0 comments on commit eea0539

Please sign in to comment.