mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
opt ctx.Plugin
This commit is contained in:
parent
b9f2557f1d
commit
91ff14f7bb
@ -732,7 +732,7 @@ func main() {
|
||||
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
|
||||
}},
|
||||
@ -790,8 +790,8 @@ func main() {
|
||||
|
||||
if m.Cmdy("cli.system", env, "go", "build", o, "-o", q, p); m.Result(0) == "" {
|
||||
m.Append("time", m.Time())
|
||||
m.Append("hash", kit.Hashs(q)[:8])
|
||||
m.Append("bin", q)
|
||||
m.Append("hash", kit.Hashs(q))
|
||||
m.Table()
|
||||
}
|
||||
}
|
||||
@ -819,7 +819,7 @@ func main() {
|
||||
for _, v := range arg[1:] {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -4,5 +4,5 @@ var version = struct {
|
||||
host string
|
||||
self int
|
||||
}{
|
||||
"2019-07-15 20:46:47", "ZYB-20190522USI.ubuntu", 168,
|
||||
"2019-07-16 10:26:05", "ZYB-20190522USI.ubuntu", 176,
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ func (c *Context) Register(s *Context, x Server, args ...interface{}) *Context {
|
||||
func (c *Context) Plugin(s *Context, args []string) string {
|
||||
c.Register(s, nil)
|
||||
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("cli.modal", "action")
|
||||
|
||||
@ -56,7 +57,10 @@ func (c *Context) Plugin(s *Context, args []string) string {
|
||||
}
|
||||
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 {
|
||||
s := &Context{Name: name, Help: help, root: c.root, context: c, message: m,
|
||||
|
@ -114,7 +114,7 @@ func dir(m *ctx.Message, name string, level int, deep bool, dir_type string, tri
|
||||
}
|
||||
}
|
||||
m.Add("append", "line", nline)
|
||||
case "hash":
|
||||
case "hash", "hashs":
|
||||
if f.IsDir() {
|
||||
d, e := ioutil.ReadDir(path.Join(name, f.Name()))
|
||||
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()))
|
||||
m.Assert(e)
|
||||
h := sha1.Sum(f)
|
||||
|
||||
if field == "hash" {
|
||||
m.Add("append", "hash", hex.EncodeToString(h[:]))
|
||||
} else {
|
||||
m.Add("append", "hash", hex.EncodeToString(h[:4]))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user