Mercurial > yakumo_izuru > aya
comparison zs_util.go @ 24:d052f3a44195 draft
fixed output file names in html pages, fixed amber function bindings, replaced print command with build, fixed plugin functions, implemented zs and exec functions
author | zaitsev.serge |
---|---|
date | Sun, 30 Aug 2015 12:22:00 +0000 |
parents | 40f55059fbfa |
children | b2f491299cee |
comparison
equal
deleted
inserted
replaced
23:40f55059fbfa | 24:d052f3a44195 |
---|---|
17 } | 17 } |
18 | 18 |
19 func pluginFunc(cmd string, vars Vars) func(args ...string) string { | 19 func pluginFunc(cmd string, vars Vars) func(args ...string) string { |
20 return func(args ...string) string { | 20 return func(args ...string) string { |
21 out := bytes.NewBuffer(nil) | 21 out := bytes.NewBuffer(nil) |
22 if err := run(cmd, args, vars, out); err != nil { | 22 if err := run(filepath.Join(ZSDIR, cmd), args, vars, out); err != nil { |
23 return cmd + ":" + err.Error() | 23 return cmd + ":" + err.Error() |
24 } else { | 24 } else { |
25 return string(out.Bytes()) | 25 return string(out.Bytes()) |
26 } | 26 } |
27 } | 27 } |
28 } | 28 } |
29 | 29 |
30 func builtins() Funcs { | 30 func builtins() Funcs { |
31 exec := func(s ...string) string { | 31 exec := func(cmd string, args ...string) string { |
32 out := bytes.NewBuffer(nil) | |
33 if err := run(cmd, args, Vars{}, out); err != nil { | |
34 return cmd + ":" + err.Error() | |
35 } else { | |
36 return string(out.Bytes()) | |
37 } | |
32 return "" | 38 return "" |
33 } | 39 } |
34 return Funcs{ | 40 return Funcs{ |
35 "exec": exec, | 41 "exec": exec, |
36 "zs": func(args ...string) string { | 42 "zs": func(args ...string) string { |
37 cmd := []string{"zs"} | 43 return exec(os.Args[0], args...) |
38 cmd = append(cmd, args...) | |
39 return exec(cmd...) | |
40 }, | 44 }, |
41 } | 45 } |
42 } | 46 } |
43 | 47 |
44 func renameExt(path, from, to string) string { | 48 func renameExt(path, from, to string) string { |