mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 09:34:05 +08:00
opt some
This commit is contained in:
parent
816a8a1584
commit
edeae0027f
@ -1,13 +1,12 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/ctx"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/user"
|
||||
@ -95,6 +94,27 @@ var Index = &ice.Context{Name: "cli", Help: "命令模块",
|
||||
m.Save(RUNTIME, SYSTEM, DAEMON)
|
||||
}},
|
||||
|
||||
"proc": {Name: "proc name=auto PID=auto auto", Help: "进程管理", Action: map[string]*ice.Action{
|
||||
"kill": {Name: "kill", Help: "结束", Hand: func(m *ice.Message, arg ...string) {
|
||||
if p, e := os.FindProcess(kit.Int(m.Option("PID"))); m.Assert(e) {
|
||||
m.Assert(p.Kill())
|
||||
}
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
msg := m.Spawn()
|
||||
msg.Split(m.Cmdx(SYSTEM, "ps", "aux"), "", " ", "\n")
|
||||
msg.Table(func(index int, value map[string]string, head []string) {
|
||||
if m.Appendv(ice.MSG_APPEND, "action", head); len(arg) == 2 && value["PID"] == arg[1] {
|
||||
m.Push("action", m.Cmdx(mdb.RENDER, "button", "结束"))
|
||||
m.Push("", value)
|
||||
return
|
||||
}
|
||||
if len(arg) == 0 || len(arg) == 1 && strings.Contains(value["COMMAND"], arg[0]) {
|
||||
m.Push("action", m.Cmdx(mdb.RENDER, "button", "结束"))
|
||||
m.Push("", value)
|
||||
}
|
||||
})
|
||||
}},
|
||||
RUNTIME: {Name: "runtime name auto", Help: "运行环境", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
switch kit.Select("", arg, 0) {
|
||||
case "procinfo":
|
||||
|
@ -58,6 +58,7 @@ func init() {
|
||||
f.WriteString(`Volcanos.meta.pack = ` + kit.Formats(kit.UnMarshal(m.Option("content"))))
|
||||
}
|
||||
|
||||
m.Option(nfs.DIR_ROOT, "")
|
||||
if f, p, e := kit.Create("usr/publish/webpack/" + m.Option("name") + ".html"); m.Assert(e) {
|
||||
f.WriteString(fmt.Sprintf(_pack,
|
||||
m.Cmdx(nfs.CAT, "usr/volcanos/cache.css"),
|
||||
|
@ -78,6 +78,7 @@ func _c_help(m *ice.Message, section, key string) string {
|
||||
return string(res)
|
||||
}
|
||||
|
||||
const CC = "cc"
|
||||
const C = "c"
|
||||
const H = "h"
|
||||
const MAN1 = "man1"
|
||||
@ -96,6 +97,10 @@ func init() {
|
||||
Index.Register(&ice.Context{Name: C, Help: "c",
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, CC, C, c.Cap(ice.CTX_FOLLOW))
|
||||
m.Cmd(mdb.PLUGIN, mdb.CREATE, CC, C, c.Cap(ice.CTX_FOLLOW))
|
||||
m.Cmd(mdb.RENDER, mdb.CREATE, CC, C, c.Cap(ice.CTX_FOLLOW))
|
||||
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, C, C, c.Cap(ice.CTX_FOLLOW))
|
||||
m.Cmd(mdb.PLUGIN, mdb.CREATE, C, C, c.Cap(ice.CTX_FOLLOW))
|
||||
m.Cmd(mdb.RENDER, mdb.CREATE, C, C, c.Cap(ice.CTX_FOLLOW))
|
||||
|
@ -40,8 +40,11 @@ func init() {
|
||||
m.Cmd(mdb.INSERT, m.Prefix(INSTALL), "", mdb.HASH, kit.MDB_NAME, name, kit.MDB_LINK, arg[0])
|
||||
m.Richs(INSTALL, "", name, func(key string, value map[string]interface{}) {
|
||||
m.Optionv("progress", func(size int, total int) {
|
||||
value["progress"], value["size"], value["total"] = size*100/total, size, total
|
||||
p := size * 100 / total
|
||||
if p != kit.Int(value["progress"]) && p%10 == 0 {
|
||||
m.Log_IMPORT(kit.MDB_FILE, name, "per", size*100/total, kit.MDB_SIZE, kit.FmtSize(int64(size)), "total", kit.FmtSize(int64(total)))
|
||||
}
|
||||
value["progress"], value["size"], value["total"] = p, size, total
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -179,13 +179,10 @@ var Index = &ice.Context{Name: GIT, Help: "代码库",
|
||||
del = dels[0]
|
||||
// } else if adds[1] == "insertions(+)" {
|
||||
} else if strings.Contains(adds[1], "insertion") {
|
||||
m.Debug("what %v", fs)
|
||||
add = adds[0]
|
||||
} else {
|
||||
m.Debug("what %v", adds[1])
|
||||
del = adds[0]
|
||||
}
|
||||
m.Debug("what %v", fs)
|
||||
}
|
||||
|
||||
if total {
|
||||
|
Loading…
x
Reference in New Issue
Block a user