From 05248fcf44987c50871dc5c3db903abdb486f0ee Mon Sep 17 00:00:00 2001 From: Adrian Hesketh Date: Fri, 3 Nov 2023 11:02:18 +0000 Subject: [PATCH] fix: return exit code, fixes #278 (#281) --- cmd/templ/main.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/cmd/templ/main.go b/cmd/templ/main.go index 4bdbcf02b..1dd17d0ef 100644 --- a/cmd/templ/main.go +++ b/cmd/templ/main.go @@ -15,7 +15,10 @@ import ( ) func main() { - run(os.Stdout, os.Args) + code := run(os.Stdout, os.Args) + if code != 0 { + os.Exit(code) + } } const usageText = `usage: templ [...] @@ -39,23 +42,19 @@ func run(w io.Writer, args []string) (code int) { } switch args[1] { case "generate": - generateCmd(w, args[2:]) - return + return generateCmd(w, args[2:]) case "migrate": - migrateCmd(w, args[2:]) - return + return migrateCmd(w, args[2:]) case "fmt": - fmtCmd(w, args[2:]) - return + return fmtCmd(w, args[2:]) case "lsp": - lspCmd(w, args[2:]) - return + return lspCmd(w, args[2:]) case "version": fmt.Fprintln(w, templ.Version) - return + return 0 case "--version": fmt.Fprintln(w, templ.Version) - return + return 0 } fmt.Fprint(w, usageText) return 0