mirror of
https://git.mills.io/prologic/zs
synced 2025-01-31 04:11:41 +03:00
moved eval func type to the top, added some error logs
This commit is contained in:
parent
77e36b532e
commit
2895462bca
8
zs.go
8
zs.go
@ -21,6 +21,8 @@ const (
|
||||
PUBDIR = ".pub"
|
||||
)
|
||||
|
||||
type EvalFn func(args []string, vars map[string]string) (string, error)
|
||||
|
||||
func split2(s, delim string) (string, string) {
|
||||
parts := strings.SplitN(s, delim, 2)
|
||||
if len(parts) == 2 {
|
||||
@ -43,8 +45,6 @@ func md(s string) (map[string]string, string) {
|
||||
return v, body
|
||||
}
|
||||
|
||||
type EvalFn func(args []string, vars map[string]string) (string, error)
|
||||
|
||||
func render(s string, vars map[string]string, eval EvalFn) (string, error) {
|
||||
b := []byte(s)
|
||||
delim_open := []byte("{{")
|
||||
@ -228,7 +228,7 @@ func main() {
|
||||
buildAll(false) // pass duration
|
||||
case "var":
|
||||
if len(args) == 0 {
|
||||
// print error
|
||||
log.Println("ERROR: filename expected")
|
||||
return
|
||||
}
|
||||
if b, err := ioutil.ReadFile(args[0]); err == nil {
|
||||
@ -244,7 +244,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// print error
|
||||
log.Println(err)
|
||||
}
|
||||
default:
|
||||
cmd := exec.Command(path.Join(ZSDIR, cmd), args...)
|
||||
|
Loading…
x
Reference in New Issue
Block a user