Skip to content

Commit

Permalink
fix: return exit code, fixes #278
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h committed Nov 3, 2023
1 parent 49f8001 commit 543f472
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions cmd/templ/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command> [<args>...]
Expand All @@ -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
Expand Down

0 comments on commit 543f472

Please sign in to comment.