mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
Merge branch 'master' of github.com:shylinux/context
This commit is contained in:
commit
df2cb8faf0
@ -4,4 +4,7 @@
|
||||
~ssh
|
||||
config domain tce
|
||||
dial "shylinux.com:9090"
|
||||
~nfs
|
||||
command add git status
|
||||
command add git branch
|
||||
|
||||
|
@ -47,8 +47,10 @@ func (cli *CLI) Spawn(m *ctx.Message, c *ctx.Context, arg ...string) ctx.Server
|
||||
s.lex = cli.lex
|
||||
s.yac = cli.yac
|
||||
s.nfs = cli.nfs
|
||||
// s.target = cli.target
|
||||
s.target = c
|
||||
s.target = cli.target
|
||||
if len(arg) > 0 {
|
||||
s.target = c
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
@ -103,7 +105,7 @@ func (cli *CLI) Begin(m *ctx.Message, arg ...string) ctx.Server { // {{{
|
||||
yac.Cmd("train", "num", "num", "mul{", "[1-9][0-9]*", "0[0-9]+", "0x[0-9]+", "}")
|
||||
yac.Cmd("train", "str", "str", "mul{", "\"[^\"]*\"", "'[^']*'", "}")
|
||||
|
||||
yac.Cmd("train", "tran", "tran", "mul{", "@", "$", "}", "opt{", "[a-zA-Z0-9]+", "}")
|
||||
yac.Cmd("train", "tran", "tran", "mul{", "@", "$", "}", "opt{", "[a-zA-Z0-9_]+", "}")
|
||||
yac.Cmd("train", "word", "word", "mul{", "~", "!", "tran", "str", "[a-zA-Z0-9_/.:]+", "}")
|
||||
|
||||
yac.Cmd("train", "op1", "op1", "mul{", "$", "@", "}")
|
||||
@ -319,25 +321,34 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
}
|
||||
} // }}}
|
||||
}},
|
||||
"time": &ctx.Command{Name: "time format when", Help: "睡眠, time(ns/us/ms/s/m/h): 时间值(纳秒/微秒/毫秒/秒/分钟/小时)", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
t := time.Now() // {{{
|
||||
if len(arg) > 1 {
|
||||
n, e := strconv.Atoi(arg[1])
|
||||
m.Assert(e)
|
||||
t = time.Unix(int64(n), 0)
|
||||
}
|
||||
"time": &ctx.Command{Name: "time [parse format when] format when",
|
||||
Formats: map[string]int{"parse": 2},
|
||||
Help: "睡眠, time(ns/us/ms/s/m/h): 时间值(纳秒/微秒/毫秒/秒/分钟/小时)", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
t := time.Now() // {{{
|
||||
if m.Options("parse") {
|
||||
f := "2006-01-02 15:04:05"
|
||||
n, e := time.Parse(f, m.Option("parse"))
|
||||
m.Assert(e)
|
||||
t = n
|
||||
}
|
||||
|
||||
f := ""
|
||||
if len(arg) > 0 {
|
||||
f = arg[0]
|
||||
}
|
||||
if len(arg) > 1 {
|
||||
n, e := strconv.Atoi(arg[1])
|
||||
m.Assert(e)
|
||||
t = time.Unix(int64(n), 0)
|
||||
}
|
||||
|
||||
if f == "" {
|
||||
m.Echo("%d", t.Unix())
|
||||
} else {
|
||||
m.Echo(t.Format(f))
|
||||
} // }}}
|
||||
}},
|
||||
f := ""
|
||||
if len(arg) > 0 {
|
||||
f = arg[0]
|
||||
}
|
||||
|
||||
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) {
|
||||
result := "false" // {{{
|
||||
switch len(arg) {
|
||||
|
@ -948,13 +948,14 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
m.Echo(wd) // }}}
|
||||
}},
|
||||
"git": &ctx.Command{Name: "git", Help: "写入文件, string: 写入内容, pos: 写入位置", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
cmd := exec.Command("git", arg...)
|
||||
cmd := exec.Command("git", arg...) // {{{
|
||||
if out, e := cmd.CombinedOutput(); e != nil {
|
||||
m.Echo("error: ")
|
||||
m.Echo("%s\n", e)
|
||||
} else {
|
||||
m.Echo(string(out))
|
||||
}
|
||||
// }}}
|
||||
}},
|
||||
},
|
||||
Index: map[string]*ctx.Context{
|
||||
|
Loading…
x
Reference in New Issue
Block a user