forked from x/ContextOS
mac pro some
This commit is contained in:
parent
d0c3239901
commit
85db6fb817
@ -13,8 +13,13 @@ syn keyword shStatement break cd chdir continue eval exec exit kill newgrp pwd r
|
|||||||
syn keyword shStatement source return function
|
syn keyword shStatement source return function
|
||||||
syn keyword shStatement if else elif end for
|
syn keyword shStatement if else elif end for
|
||||||
syn keyword shStatement let var
|
syn keyword shStatement let var
|
||||||
syn keyword shStatement cache
|
|
||||||
syn keyword shStatement config
|
syn match shStatement "\(^\|\t\|$(\)cache"
|
||||||
|
syn match shStatement "\(^\|\t\|$(\)config"
|
||||||
|
syn match shStatement "\(^\|\t\|$(\)detail"
|
||||||
|
syn match shStatement "\(^\|\t\|$(\)option"
|
||||||
|
syn match shStatement "\(^\|\t\|$(\)append"
|
||||||
|
syn match shStatement "\(^\|\t\|$(\)result"
|
||||||
|
|
||||||
syn keyword shCommand command
|
syn keyword shCommand command
|
||||||
syn keyword shCommand open
|
syn keyword shCommand open
|
||||||
|
@ -270,6 +270,8 @@ func (cli *CLI) Close(m *ctx.Message, arg ...string) bool { // {{{
|
|||||||
if _, ok := m.Source().Server.(*CLI); ok {
|
if _, ok := m.Source().Server.(*CLI); ok {
|
||||||
// p.target = cli.target
|
// p.target = cli.target
|
||||||
}
|
}
|
||||||
|
msg := m.Sesss("nfs")
|
||||||
|
msg.Target().Close(msg)
|
||||||
case m.Source():
|
case m.Source():
|
||||||
if m.Name == "aaa" {
|
if m.Name == "aaa" {
|
||||||
if !cli.Context.Close(m.Spawn(cli.Context), arg...) {
|
if !cli.Context.Close(m.Spawn(cli.Context), arg...) {
|
||||||
@ -285,13 +287,13 @@ func (cli *CLI) Close(m *ctx.Message, arg ...string) bool { // {{{
|
|||||||
|
|
||||||
var Pulse *ctx.Message
|
var Pulse *ctx.Message
|
||||||
var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||||
Caches: map[string]*ctx.Cache{},
|
Caches: map[string]*ctx.Cache{
|
||||||
Configs: map[string]*ctx.Config{
|
"time": &ctx.Cache{Name: "time", Value: "0", Help: "所有模块的当前目录", Hand: func(m *ctx.Message, x *ctx.Cache, arg ...string) string {
|
||||||
"time": &ctx.Config{Name: "time", Value: "0", Help: "所有模块的当前目录", Hand: func(m *ctx.Message, x *ctx.Config, arg ...string) string {
|
|
||||||
t := time.Now().Unix()
|
t := time.Now().Unix()
|
||||||
return fmt.Sprintf("%d", t)
|
return fmt.Sprintf("%d", t)
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
Configs: map[string]*ctx.Config{},
|
||||||
Commands: map[string]*ctx.Command{
|
Commands: map[string]*ctx.Command{
|
||||||
"alias": &ctx.Command{Name: "alias [short [long]]|[delete short]", Help: "查看、定义或删除命令别名, short: 命令别名, long: 命令原名, delete: 删除别名", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"alias": &ctx.Command{Name: "alias [short [long]]|[delete short]", Help: "查看、定义或删除命令别名, short: 命令别名, long: 命令原名, delete: 删除别名", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
if cli, ok := m.Target().Server.(*CLI); m.Assert(ok) && !m.Caps("skip") { // {{{
|
if cli, ok := m.Target().Server.(*CLI); m.Assert(ok) && !m.Caps("skip") { // {{{
|
||||||
@ -322,30 +324,26 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
}
|
}
|
||||||
} // }}}
|
} // }}}
|
||||||
}},
|
}},
|
||||||
"time": &ctx.Command{Name: "time [parse when] format when",
|
"time": &ctx.Command{Name: "time [parse when] when",
|
||||||
Form: map[string]int{"parse": 1},
|
Form: map[string]int{"parse": 1},
|
||||||
Help: "睡眠, time(ns/us/ms/s/m/h): 时间值(纳秒/微秒/毫秒/秒/分钟/小时)", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
Help: "睡眠, time(ns/us/ms/s/m/h): 时间值(纳秒/微秒/毫秒/秒/分钟/小时)", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
t := time.Now() // {{{
|
t := time.Now() // {{{
|
||||||
|
f := "2006-01-02 15:04:05"
|
||||||
|
if len(arg) > 0 {
|
||||||
|
if i, e := strconv.Atoi(arg[0]); e == nil {
|
||||||
|
t = time.Unix(int64(i), 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
if m.Options("parse") {
|
if m.Options("parse") {
|
||||||
f := "2006-01-02 15:04:05"
|
|
||||||
n, e := time.ParseInLocation(f, m.Option("parse"), time.Local)
|
n, e := time.ParseInLocation(f, m.Option("parse"), time.Local)
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
t = n
|
t = n
|
||||||
}
|
}
|
||||||
|
|
||||||
f := ""
|
m.Echo("%d", t.Unix())
|
||||||
if len(arg) > 0 {
|
m.Echo(" ")
|
||||||
n, e := strconv.Atoi(arg[0])
|
m.Echo(t.Format(f))
|
||||||
m.Assert(e)
|
// }}}
|
||||||
t = time.Unix(int64(n), 0)
|
|
||||||
f = "2006-01-02 15:04:05"
|
|
||||||
}
|
|
||||||
|
|
||||||
if f == "" {
|
|
||||||
m.Echo("%d", t.Unix())
|
|
||||||
} else {
|
|
||||||
m.Echo(t.Format(f))
|
|
||||||
} // }}}
|
|
||||||
}},
|
}},
|
||||||
"express": &ctx.Command{Name: "express exp", Help: "表达式运算", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"express": &ctx.Command{Name: "express exp", Help: "表达式运算", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
result := "false" // {{{
|
result := "false" // {{{
|
||||||
@ -569,19 +567,13 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
case "@":
|
case "@":
|
||||||
m.Echo(msg.Conf(arg[1]))
|
m.Echo(msg.Conf(arg[1]))
|
||||||
}
|
}
|
||||||
case 4:
|
|
||||||
switch arg[0] {
|
|
||||||
case "$":
|
|
||||||
m.Echo(arg[2])
|
|
||||||
case "@":
|
|
||||||
m.Echo(arg[2])
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
|
last := len(arg) - 1
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case "$":
|
case "$":
|
||||||
m.Result(0, "cache", arg[1:])
|
m.Result(0, arg[2:last])
|
||||||
case "@":
|
case "@":
|
||||||
m.Result(0, "config", arg[1:])
|
m.Result(0, arg[2:last])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2434,7 +2434,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
}},
|
}},
|
||||||
"detail": &Command{Name: "detail [index]", Help: "查看或添加参数", Hand: func(m *Message, c *Context, key string, arg ...string) {
|
"detail": &Command{Name: "detail [index [value...]]", Help: "查看或添加参数", Hand: func(m *Message, c *Context, key string, arg ...string) {
|
||||||
msg := m.Sesss("cli", false) // {{{
|
msg := m.Sesss("cli", false) // {{{
|
||||||
switch len(arg) {
|
switch len(arg) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -2475,7 +2475,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
case 0:
|
case 0:
|
||||||
m.Echo("%v\n", msg.Meta["result"])
|
m.Echo("%v\n", msg.Meta["result"])
|
||||||
default:
|
default:
|
||||||
msg.Set("result", arg...)
|
msg.Result(-2, arg)
|
||||||
} // }}}
|
} // }}}
|
||||||
}},
|
}},
|
||||||
"append": &Command{Name: "append [key [value...]]", Help: "查看或添加附加值", Hand: func(m *Message, c *Context, key string, arg ...string) {
|
"append": &Command{Name: "append [key [value...]]", Help: "查看或添加附加值", Hand: func(m *Message, c *Context, key string, arg ...string) {
|
||||||
|
@ -17,7 +17,6 @@ import ( // {{{
|
|||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"bufio"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@ -200,7 +199,6 @@ func (web *WEB) Spawn(m *ctx.Message, c *ctx.Context, arg ...string) ctx.Server
|
|||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
func (web *WEB) Begin(m *ctx.Message, arg ...string) ctx.Server { // {{{
|
func (web *WEB) Begin(m *ctx.Message, arg ...string) ctx.Server { // {{{
|
||||||
m.Sesss("cli", "cli")
|
|
||||||
web.Context.Master(nil)
|
web.Context.Master(nil)
|
||||||
web.Caches["route"] = &ctx.Cache{Name: "请求路径", Value: "/" + web.Context.Name + "/", Help: "请求路径"}
|
web.Caches["route"] = &ctx.Cache{Name: "请求路径", Value: "/" + web.Context.Name + "/", Help: "请求路径"}
|
||||||
web.Caches["register"] = &ctx.Cache{Name: "已初始化(yes/no)", Value: "no", Help: "模块是否已初始化"}
|
web.Caches["register"] = &ctx.Cache{Name: "已初始化(yes/no)", Value: "no", Help: "模块是否已初始化"}
|
||||||
@ -277,7 +275,7 @@ func (web *WEB) Start(m *ctx.Message, arg ...string) bool { // {{{
|
|||||||
m.Log("info", nil, "protocol [%s]", m.Cap("protocol"))
|
m.Log("info", nil, "protocol [%s]", m.Cap("protocol"))
|
||||||
web.Server = &http.Server{Addr: m.Cap("address"), Handler: web}
|
web.Server = &http.Server{Addr: m.Cap("address"), Handler: web}
|
||||||
|
|
||||||
web.Configs["logheaders"] = &ctx.Config{Name: "日志输出报文头(yes/no)", Value: "yes", Help: "日志输出报文头"}
|
web.Configs["logheaders"] = &ctx.Config{Name: "日志输出报文头(yes/no)", Value: "no", Help: "日志输出报文头"}
|
||||||
m.Capi("nserve", 1)
|
m.Capi("nserve", 1)
|
||||||
|
|
||||||
if web.Message = m; m.Cap("protocol") == "https" {
|
if web.Message = m; m.Cap("protocol") == "https" {
|
||||||
@ -524,27 +522,9 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
case "script":
|
case "script":
|
||||||
cli := m.Find("cli")
|
|
||||||
lex := m.Find("lex")
|
|
||||||
mux.Trans(m, arg[1], func(m *ctx.Message, c *ctx.Context, key string, a ...string) {
|
mux.Trans(m, arg[1], func(m *ctx.Message, c *ctx.Context, key string, a ...string) {
|
||||||
f, e := os.Open(arg[2])
|
msg := m.Find("cli").Cmd("source", arg[2])
|
||||||
line, bio := "", bufio.NewReader(f)
|
m.Copy(msg, "result").Copy(msg, "append")
|
||||||
if e != nil {
|
|
||||||
line = arg[2]
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
|
||||||
if line = strings.TrimSpace(line); line != "" {
|
|
||||||
lex.Cmd("split", line, "void")
|
|
||||||
cli.Wait = make(chan bool)
|
|
||||||
cli.Cmd(lex.Meta["result"])
|
|
||||||
m.Meta["result"] = cli.Meta["result"]
|
|
||||||
}
|
|
||||||
|
|
||||||
if line, e = bio.ReadString('\n'); e != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} // }}}
|
} // }}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user