From e2b4d9c8c553d67e26d0d05998004692210e39bf Mon Sep 17 00:00:00 2001 From: Izuru Yakumo Date: Tue, 21 Nov 2023 08:44:14 -0300 Subject: [PATCH] The World (XXI) * Replace all iterations of log.* with fmt.* and os.Exit() * Use proper Go versioning Signed-off-by: Izuru Yakumo --- cmd/aya/main.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/cmd/aya/main.go b/cmd/aya/main.go index d05b1f5..0177695 100644 --- a/cmd/aya/main.go +++ b/cmd/aya/main.go @@ -5,7 +5,6 @@ import ( "bytes" "fmt" "io" - "log" "os" "os/exec" "path/filepath" @@ -78,7 +77,7 @@ func run(vars Vars, cmd string, args ...string) (string, error) { err := c.Run() if errbuf.Len() > 0 { - log.Println("ERROR:", errbuf.String()) + fmt.Println("ERROR:", errbuf.String()) } if err != nil { return "", err @@ -350,7 +349,7 @@ func buildAll(watch bool) { run(vars, "prehook") modified = true } - log.Println("build:", path) + fmt.Println("build:", path) return build(path, nil, vars) } return nil @@ -402,13 +401,15 @@ func main() { buildAll(false) } else if len(args) == 1 { if err := build(args[0], os.Stdout, globals()); err != nil { - log.Fatal("ERROR: " + err.Error()) + fmt.Println("ERROR: " + err.Error()) + os.Exit(1) } } else { - log.Fatal("ERROR: too many arguments") + fmt.Println("ERROR: too many arguments") + os.Exit(1) } case "clean": - log.Println("Removing generated site directory") + fmt.Println("Removing generated site directory") os.RemoveAll(PUBDIR) case "help": printUsage() @@ -416,7 +417,8 @@ func main() { aya.HttpServe(PUBDIR) case "var": if len(args) == 0 { - log.Fatal("var: filename expected") + fmt.Println("var: filename expected") + os.Exit(1) } else { s := "" if vars, _, err := getVars(args[0], Vars{}); err != nil { @@ -441,9 +443,9 @@ func main() { buildAll(true) default: if s, err := run(globals(), cmd, args...); err != nil { - log.Println(err) + fmt.Println(err) } else { - log.Println(s) + fmt.Println(s) } } } -- 2.43.0