The World (XXI)

* Replace all iterations of log.* with fmt.* and os.Exit()
* Use proper Go versioning

Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>

git-svn-id: file:///srv/svn/repo/aya/trunk@74 cec141ff-132a-4243-88a5-ce187bd62f94
This commit is contained in:
yakumo.izuru
2023-11-21 11:44:14 +00:00
parent 34cc1312ba
commit 5dbb5fe308

View File

@@ -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)
}
}
}