forked from x/icebergs
opt some
This commit is contained in:
parent
48e7c676d6
commit
137a5d61a2
@ -14,10 +14,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Frame struct {
|
type Frame struct {
|
||||||
in io.ReadCloser
|
in io.ReadCloser
|
||||||
out io.Writer
|
out io.Writer
|
||||||
|
|
||||||
target *ice.Context
|
target *ice.Context
|
||||||
count int
|
count int
|
||||||
|
exit bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frame) prompt(m *ice.Message) *Frame {
|
func (f *Frame) prompt(m *ice.Message) *Frame {
|
||||||
@ -141,7 +143,7 @@ func (f *Frame) Start(m *ice.Message, arg ...string) bool {
|
|||||||
|
|
||||||
line := ""
|
line := ""
|
||||||
bio := bufio.NewScanner(f.in)
|
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 {
|
if len(bio.Text()) == 0 {
|
||||||
// 空行
|
// 空行
|
||||||
continue
|
continue
|
||||||
@ -247,6 +249,11 @@ var Index = &ice.Context{Name: "ssh", Help: "终端模块",
|
|||||||
m.Info("%v", ls)
|
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) {
|
"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(
|
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 {
|
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") {
|
if msg.Optionv(ice.MSG_HANDLE, "true"); !msg.Warn(!safe, "no right") {
|
||||||
m.Option("_dev", name)
|
m.Option("_dev", name)
|
||||||
msg = msg.Cmd()
|
msg = msg.Cmd()
|
||||||
|
@ -49,7 +49,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
"some", kit.Dict("simple", kit.Dict(
|
"some", kit.Dict("simple", kit.Dict(
|
||||||
"inputs", kit.List(
|
"inputs", kit.List(
|
||||||
kit.MDB_INPUT, "text", "name", "name",
|
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",
|
kit.MDB_INPUT, "button", "value", "返回", "cb", "Last",
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
@ -240,26 +240,23 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
m.Option(kit.MDB_NAME, arg[0])
|
m.Option(kit.MDB_NAME, arg[0])
|
||||||
m.Option(kit.MDB_TEXT, arg[1])
|
m.Option(kit.MDB_TEXT, arg[1])
|
||||||
|
|
||||||
if len(arg) > 2 {
|
if meta := m.Confv("field", kit.Keys("meta.some", kit.Select("simple", arg, 2))); meta != nil {
|
||||||
if meta := m.Confv("field", kit.Keys("meta.some", arg[2])); meta != nil {
|
m.Option("meta", meta)
|
||||||
arg = arg[3:]
|
} else {
|
||||||
m.Option("meta", meta)
|
list := []string{}
|
||||||
} else {
|
for _, line := range kit.Split(strings.Join(arg[2:], " "), "\n") {
|
||||||
list := []string{}
|
ls := kit.Split(line)
|
||||||
for _, line := range kit.Split(strings.Join(arg[2:], " "), "\n") {
|
for i := 0; i < len(ls); i++ {
|
||||||
ls := kit.Split(line)
|
if strings.HasPrefix(ls[i], "#") {
|
||||||
for i := 0; i < len(ls); i++ {
|
ls = ls[:i]
|
||||||
if strings.HasPrefix(ls[i], "#") {
|
break
|
||||||
ls = ls[:i]
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
list = append(list, ls...)
|
|
||||||
}
|
}
|
||||||
|
list = append(list, ls...)
|
||||||
meta := kit.Parse(nil, "", list...)
|
|
||||||
m.Option("meta", meta)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
meta := kit.Parse(nil, "", list...)
|
||||||
|
m.Option("meta", meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Render(m.Conf(cmd, "meta.template"))
|
m.Render(m.Conf(cmd, "meta.template"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user