mirror of
https://git.mills.io/prologic/zs
synced 2025-01-31 12:21:42 +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"
|
PUBDIR = ".pub"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type EvalFn func(args []string, vars map[string]string) (string, error)
|
||||||
|
|
||||||
func split2(s, delim string) (string, string) {
|
func split2(s, delim string) (string, string) {
|
||||||
parts := strings.SplitN(s, delim, 2)
|
parts := strings.SplitN(s, delim, 2)
|
||||||
if len(parts) == 2 {
|
if len(parts) == 2 {
|
||||||
@ -43,8 +45,6 @@ func md(s string) (map[string]string, string) {
|
|||||||
return v, body
|
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) {
|
func render(s string, vars map[string]string, eval EvalFn) (string, error) {
|
||||||
b := []byte(s)
|
b := []byte(s)
|
||||||
delim_open := []byte("{{")
|
delim_open := []byte("{{")
|
||||||
@ -228,7 +228,7 @@ func main() {
|
|||||||
buildAll(false) // pass duration
|
buildAll(false) // pass duration
|
||||||
case "var":
|
case "var":
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
// print error
|
log.Println("ERROR: filename expected")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if b, err := ioutil.ReadFile(args[0]); err == nil {
|
if b, err := ioutil.ReadFile(args[0]); err == nil {
|
||||||
@ -244,7 +244,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// print error
|
log.Println(err)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
cmd := exec.Command(path.Join(ZSDIR, cmd), args...)
|
cmd := exec.Command(path.Join(ZSDIR, cmd), args...)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user