mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-29 10:19:21 +08:00
mod cli.source to sync
This commit is contained in:
parent
46a3bbc8ef
commit
66008f3a8a
11
etc/init.shy
11
etc/init.shy
@ -1,6 +1,7 @@
|
|||||||
source etc/local.shy
|
~aaa
|
||||||
login root root
|
login root root
|
||||||
~ssh
|
|
||||||
#dial "shylinux.com:9090"
|
~ssh
|
||||||
command add pwd _
|
config domain ctx
|
||||||
|
dial "shylinux.com:9090"
|
||||||
|
|
||||||
|
@ -47,7 +47,8 @@ func (cli *CLI) Spawn(m *ctx.Message, c *ctx.Context, arg ...string) ctx.Server
|
|||||||
s.lex = cli.lex
|
s.lex = cli.lex
|
||||||
s.yac = cli.yac
|
s.yac = cli.yac
|
||||||
s.nfs = cli.nfs
|
s.nfs = cli.nfs
|
||||||
s.target = cli.target
|
// s.target = cli.target
|
||||||
|
s.target = c
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,6 +660,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
"source": &ctx.Command{Name: "source file", Help: "运行脚本, file: 脚本文件名", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"source": &ctx.Command{Name: "source file", Help: "运行脚本, file: 脚本文件名", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
if _, ok := m.Target().Server.(*CLI); m.Assert(ok) && !m.Caps("skip") { // {{{
|
if _, ok := m.Target().Server.(*CLI); m.Assert(ok) && !m.Caps("skip") { // {{{
|
||||||
m.Start(fmt.Sprintf("%s_%d_%s", key, m.Optioni("level", m.Capi("level")+1), arg[0]), "脚本文件", arg[0])
|
m.Start(fmt.Sprintf("%s_%d_%s", key, m.Optioni("level", m.Capi("level")+1), arg[0]), "脚本文件", arg[0])
|
||||||
|
<-m.Target().Exit
|
||||||
} // }}}
|
} // }}}
|
||||||
}},
|
}},
|
||||||
"return": &ctx.Command{Name: "return result...", Help: "结束脚本, rusult: 返回值", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"return": &ctx.Command{Name: "return result...", Help: "结束脚本, rusult: 返回值", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
|
@ -306,7 +306,9 @@ func (c *Context) Close(m *Message, arg ...string) bool { // {{{
|
|||||||
delete(c.context.contexts, c.Name)
|
delete(c.context.contexts, c.Name)
|
||||||
c.context = nil
|
c.context = nil
|
||||||
if c.Exit != nil {
|
if c.Exit != nil {
|
||||||
|
m.Log("info", nil, "before exit<-")
|
||||||
c.Exit <- true
|
c.Exit <- true
|
||||||
|
m.Log("info", nil, "after exit<-")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -1279,6 +1281,11 @@ func (m *Message) Start(name string, help string, arg ...string) bool { // {{{
|
|||||||
return m.Set("detail", arg...).target.Spawn(m, name, help).Begin(m).Start(m)
|
return m.Set("detail", arg...).target.Spawn(m, name, help).Begin(m).Start(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
func (m *Message) Starts(name string, help string, arg ...string) bool { // {{{
|
||||||
|
return m.Set("detail", arg...).target.Spawn(m, name, help).Begin(m).Start(m)
|
||||||
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
func (m *Message) Exec(key string, arg ...string) string { // {{{
|
func (m *Message) Exec(key string, arg ...string) string { // {{{
|
||||||
|
@ -55,11 +55,7 @@ func (mdb *MDB) Start(m *ctx.Message, arg ...string) bool { // {{{
|
|||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
m.Cap("source", arg[0])
|
m.Cap("source", arg[0])
|
||||||
}
|
}
|
||||||
if len(arg) > 1 {
|
|
||||||
m.Cap("driver", arg[1])
|
|
||||||
} else {
|
|
||||||
m.Cap("driver", Pulse.Conf("driver"))
|
m.Cap("driver", Pulse.Conf("driver"))
|
||||||
}
|
|
||||||
if m.Cap("source") == "" || m.Cap("driver") == "" {
|
if m.Cap("source") == "" || m.Cap("driver") == "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -284,7 +280,6 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心",
|
|||||||
m.Echo("\n")
|
m.Echo("\n")
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
// }}}
|
|
||||||
"list": &ctx.Command{Name: "list add table field [where condition]", Help: "执行查询语句",
|
"list": &ctx.Command{Name: "list add table field [where condition]", Help: "执行查询语句",
|
||||||
Formats: map[string]int{"where": 1},
|
Formats: map[string]int{"where": 1},
|
||||||
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
|
@ -556,7 +556,8 @@ func (nfs *NFS) Start(m *ctx.Message, arg ...string) bool { // {{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cli := m.Reply()
|
// cli := m.Reply()
|
||||||
|
cli := m.Sesss("cli")
|
||||||
nfs.cli = cli
|
nfs.cli = cli
|
||||||
yac := m.Sesss("yac", cli.Conf("yac"))
|
yac := m.Sesss("yac", cli.Conf("yac"))
|
||||||
bio := bufio.NewScanner(nfs)
|
bio := bufio.NewScanner(nfs)
|
||||||
|
@ -437,7 +437,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
part, e := writer.CreateFormFile(m.Option("file"), filepath.Base(m.Meta["file"][1]))
|
part, e := writer.CreateFormFile(m.Option("file"), filepath.Base(m.Meta["file"][1]))
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
|
|
||||||
io.Copy(part, file)
|
n, e := io.Copy(part, file)
|
||||||
for i := 0; i < len(arg)-1; i += 2 {
|
for i := 0; i < len(arg)-1; i += 2 {
|
||||||
writer.WriteField(arg[0], arg[1])
|
writer.WriteField(arg[0], arg[1])
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user