forked from x/icebergs
opt some
This commit is contained in:
parent
48e7c676d6
commit
137a5d61a2
@ -16,8 +16,10 @@ import (
|
||||
type Frame struct {
|
||||
in io.ReadCloser
|
||||
out io.Writer
|
||||
|
||||
target *ice.Context
|
||||
count int
|
||||
exit bool
|
||||
}
|
||||
|
||||
func (f *Frame) prompt(m *ice.Message) *Frame {
|
||||
@ -141,7 +143,7 @@ func (f *Frame) Start(m *ice.Message, arg ...string) bool {
|
||||
|
||||
line := ""
|
||||
bio := bufio.NewScanner(f.in)
|
||||
for f.prompt(m); bio.Scan(); f.prompt(m) {
|
||||
for f.prompt(m); bio.Scan() && !f.exit; f.prompt(m) {
|
||||
if len(bio.Text()) == 0 {
|
||||
// 空行
|
||||
continue
|
||||
@ -247,6 +249,11 @@ var Index = &ice.Context{Name: "ssh", Help: "终端模块",
|
||||
m.Info("%v", ls)
|
||||
}
|
||||
}},
|
||||
"return": {Name: "return", Help: "解析", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Option(ice.MSG_PROMPT, m.Confv("prompt", "meta.PS1"))
|
||||
f := m.Target().Server().(*Frame)
|
||||
f.exit = true
|
||||
}},
|
||||
|
||||
"super": {Name: "super user remote port local", Help: "上位机", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
key := m.Rich("super", nil, kit.Dict(
|
||||
|
@ -106,6 +106,8 @@ func (web *Frame) HandleWSS(m *ice.Message, safe bool, c *websocket.Conn, name s
|
||||
|
||||
if len(target) == 0 {
|
||||
// 本地执行
|
||||
msg.Option(ice.MSG_USERROLE, msg.Cmdx(ice.AAA_ROLE, "check", msg.Option(ice.MSG_USERNAME)))
|
||||
msg.Log("some", "%s: %s", msg.Option(ice.MSG_USERROLE), msg.Option(ice.MSG_USERNAME))
|
||||
if msg.Optionv(ice.MSG_HANDLE, "true"); !msg.Warn(!safe, "no right") {
|
||||
m.Option("_dev", name)
|
||||
msg = msg.Cmd()
|
||||
|
@ -49,7 +49,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
||||
"some", kit.Dict("simple", kit.Dict(
|
||||
"inputs", kit.List(
|
||||
kit.MDB_INPUT, "text", "name", "name",
|
||||
kit.MDB_INPUT, "button", "value", "查看",
|
||||
kit.MDB_INPUT, "button", "value", "查看", "action", "auto",
|
||||
kit.MDB_INPUT, "button", "value", "返回", "cb", "Last",
|
||||
),
|
||||
)),
|
||||
@ -240,9 +240,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
||||
m.Option(kit.MDB_NAME, arg[0])
|
||||
m.Option(kit.MDB_TEXT, arg[1])
|
||||
|
||||
if len(arg) > 2 {
|
||||
if meta := m.Confv("field", kit.Keys("meta.some", arg[2])); meta != nil {
|
||||
arg = arg[3:]
|
||||
if meta := m.Confv("field", kit.Keys("meta.some", kit.Select("simple", arg, 2))); meta != nil {
|
||||
m.Option("meta", meta)
|
||||
} else {
|
||||
list := []string{}
|
||||
@ -260,7 +258,6 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
||||
meta := kit.Parse(nil, "", list...)
|
||||
m.Option("meta", meta)
|
||||
}
|
||||
}
|
||||
|
||||
m.Render(m.Conf(cmd, "meta.template"))
|
||||
}},
|
||||
|
Loading…
x
Reference in New Issue
Block a user