1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00

opt ctx.Plugin

This commit is contained in:
shaoying 2019-07-16 10:45:30 +08:00
parent b9f2557f1d
commit 91ff14f7bb
4 changed files with 16 additions and 7 deletions

View File

@ -732,7 +732,7 @@ func main() {
ioutil.WriteFile(path.Join(p, kit.Format(value["name"])), []byte(kit.Format(value["text"])), 0666) ioutil.WriteFile(path.Join(p, kit.Format(value["name"])), []byte(kit.Format(value["text"])), 0666)
}) })
} }
m.Cmdy("nfs.dir", p, "time", "size", "line", "path") m.Cmdy("nfs.dir", p, "time", "line", "hashs", "path")
} }
return return
}}, }},
@ -790,8 +790,8 @@ func main() {
if m.Cmdy("cli.system", env, "go", "build", o, "-o", q, p); m.Result(0) == "" { if m.Cmdy("cli.system", env, "go", "build", o, "-o", q, p); m.Result(0) == "" {
m.Append("time", m.Time()) m.Append("time", m.Time())
m.Append("hash", kit.Hashs(q)[:8])
m.Append("bin", q) m.Append("bin", q)
m.Append("hash", kit.Hashs(q))
m.Table() m.Table()
} }
} }
@ -819,7 +819,7 @@ func main() {
for _, v := range arg[1:] { for _, v := range arg[1:] {
m.Cmd("nfs.copy", path.Join(q, v), path.Join(p, v)) m.Cmd("nfs.copy", path.Join(q, v), path.Join(p, v))
} }
m.Cmdy("nfs.dir", q, "time", "size", "hash", "path") m.Cmdy("nfs.dir", q, "time", "size", "hashs", "path")
return e return e
} }

View File

@ -4,5 +4,5 @@ var version = struct {
host string host string
self int self int
}{ }{
"2019-07-15 20:46:47", "ZYB-20190522USI.ubuntu", 168, "2019-07-16 10:26:05", "ZYB-20190522USI.ubuntu", 176,
} }

View File

@ -34,6 +34,7 @@ func (c *Context) Register(s *Context, x Server, args ...interface{}) *Context {
func (c *Context) Plugin(s *Context, args []string) string { func (c *Context) Plugin(s *Context, args []string) string {
c.Register(s, nil) c.Register(s, nil)
m := &Message{code: 0, time: time.Now(), source: s, target: s, Meta: map[string][]string{}} m := &Message{code: 0, time: time.Now(), source: s, target: s, Meta: map[string][]string{}}
kit.DisableLog = true
m.Option("log.disable", true) m.Option("log.disable", true)
m.Option("cli.modal", "action") m.Option("cli.modal", "action")
@ -56,7 +57,10 @@ func (c *Context) Plugin(s *Context, args []string) string {
} }
m.Cmd(args) m.Cmd(args)
} }
return strings.Join(m.Meta["result"], "") for _, v := range m.Meta["result"] {
m.Show(v)
}
return ""
} }
func (c *Context) Spawn(m *Message, name string, help string) *Context { func (c *Context) Spawn(m *Message, name string, help string) *Context {
s := &Context{Name: name, Help: help, root: c.root, context: c, message: m, s := &Context{Name: name, Help: help, root: c.root, context: c, message: m,

View File

@ -114,7 +114,7 @@ func dir(m *ctx.Message, name string, level int, deep bool, dir_type string, tri
} }
} }
m.Add("append", "line", nline) m.Add("append", "line", nline)
case "hash": case "hash", "hashs":
if f.IsDir() { if f.IsDir() {
d, e := ioutil.ReadDir(path.Join(name, f.Name())) d, e := ioutil.ReadDir(path.Join(name, f.Name()))
m.Assert(e) m.Assert(e)
@ -132,7 +132,12 @@ func dir(m *ctx.Message, name string, level int, deep bool, dir_type string, tri
f, e := ioutil.ReadFile(path.Join(name, f.Name())) f, e := ioutil.ReadFile(path.Join(name, f.Name()))
m.Assert(e) m.Assert(e)
h := sha1.Sum(f) h := sha1.Sum(f)
m.Add("append", "hash", hex.EncodeToString(h[:]))
if field == "hash" {
m.Add("append", "hash", hex.EncodeToString(h[:]))
} else {
m.Add("append", "hash", hex.EncodeToString(h[:4]))
}
} }
} }
} }