forked from x/ContextOS
tce add nfs.git.csv
This commit is contained in:
parent
65782a9bab
commit
dfe3d76e69
23
etc/init.shy
23
etc/init.shy
@ -1,23 +1,5 @@
|
|||||||
|
source etc/local.shy
|
||||||
if 1 + 2
|
return
|
||||||
echo "hello"
|
|
||||||
end
|
|
||||||
|
|
||||||
if 1 + 2
|
|
||||||
echo "hello"
|
|
||||||
else
|
|
||||||
echo "world"
|
|
||||||
end
|
|
||||||
|
|
||||||
if 0
|
|
||||||
echo "hello"
|
|
||||||
end
|
|
||||||
|
|
||||||
if 0
|
|
||||||
echo "hello"
|
|
||||||
else
|
|
||||||
echo "word"
|
|
||||||
end
|
|
||||||
|
|
||||||
return "hello" "world"
|
return "hello" "world"
|
||||||
source etc/demo.shy
|
source etc/demo.shy
|
||||||
@ -27,7 +9,6 @@ scan_file etc/demo.shy
|
|||||||
echo "who"
|
echo "who"
|
||||||
~web
|
~web
|
||||||
command add get "https://chat.shylinux.com"
|
command add get "https://chat.shylinux.com"
|
||||||
source etc/local.shy
|
|
||||||
|
|
||||||
~aaa
|
~aaa
|
||||||
login root root
|
login root root
|
||||||
|
@ -184,7 +184,6 @@ func (cli *CLI) Start(m *ctx.Message, arg ...string) bool { // {{{
|
|||||||
m.Option("target", m.Target().Name)
|
m.Option("target", m.Target().Name)
|
||||||
yac = m.Sesss("yac")
|
yac = m.Sesss("yac")
|
||||||
yac.Call(func(cmd *ctx.Message) *ctx.Message {
|
yac.Call(func(cmd *ctx.Message) *ctx.Message {
|
||||||
m.Log("fuck", nil, "skip: %s, level:%s %v", m.Cap("skip"), m.Cap("level"), cli.stack)
|
|
||||||
if m.Caps("skip") {
|
if m.Caps("skip") {
|
||||||
switch cmd.Detail(0) {
|
switch cmd.Detail(0) {
|
||||||
case "if":
|
case "if":
|
||||||
@ -609,7 +608,6 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
cli.stack = append(cli.stack, Frame{pos: m.Optioni("nline") - 1, key: key, run: arg[1]})
|
cli.stack = append(cli.stack, Frame{pos: m.Optioni("nline") - 1, key: key, run: arg[1]})
|
||||||
m.Capi("level", 1)
|
m.Capi("level", 1)
|
||||||
m.Caps("skip", !ctx.Right(arg[1]))
|
m.Caps("skip", !ctx.Right(arg[1]))
|
||||||
m.Log("fuck", nil, "if %v", cli.stack)
|
|
||||||
} // }}}
|
} // }}}
|
||||||
}},
|
}},
|
||||||
"else": &ctx.Command{Name: "else", Help: "条件语句", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"else": &ctx.Command{Name: "else", Help: "条件语句", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
@ -636,7 +634,13 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
} else {
|
} else {
|
||||||
m.Caps("skip", false)
|
m.Caps("skip", false)
|
||||||
}
|
}
|
||||||
m.Log("fuck", nil, "if %v", cli.stack)
|
} // }}}
|
||||||
|
}},
|
||||||
|
"for": &ctx.Command{Name: "for exp", Help: "循环语句, exp: 表达式", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
|
if cli, ok := m.Target().Server.(*CLI); m.Assert(ok) { // {{{
|
||||||
|
cli.stack = append(cli.stack, Frame{pos: m.Optioni("nline") - 1, key: key, run: arg[1]})
|
||||||
|
m.Capi("level", 1)
|
||||||
|
m.Caps("skip", !ctx.Right(arg[1]))
|
||||||
} // }}}
|
} // }}}
|
||||||
}},
|
}},
|
||||||
|
|
||||||
@ -702,20 +706,6 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
m.Caps("else", m.Caps("skip", !ctx.Right(arg[1])))
|
m.Caps("else", m.Caps("skip", !ctx.Right(arg[1])))
|
||||||
} // }}}
|
} // }}}
|
||||||
}},
|
}},
|
||||||
"for": &ctx.Command{Name: "for exp", Help: "循环语句, exp: 表达式", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
|
||||||
if _, ok := m.Target().Server.(*CLI); m.Assert(ok) { // {{{
|
|
||||||
if m.Capi("loop") != -2 && m.Capi("loop") == m.Optioni("pos")-1 {
|
|
||||||
m.Caps("skip", !ctx.Right(arg[1]))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if m.Optioni("skip", 0); m.Caps("skip") || !ctx.Right(arg[1]) {
|
|
||||||
m.Optioni("skip", m.Capi("skip")+1)
|
|
||||||
}
|
|
||||||
m.Optioni("loop", m.Optioni("pos")-1)
|
|
||||||
m.Start(fmt.Sprintf("%s%d", key, m.Optioni("level", m.Capi("level")+1)), "循环语句")
|
|
||||||
} // }}}
|
|
||||||
}},
|
|
||||||
"function": &ctx.Command{Name: "function name", Help: "函数定义, name: 函数名", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"function": &ctx.Command{Name: "function name", Help: "函数定义, name: 函数名", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
if _, ok := m.Target().Server.(*CLI); m.Assert(ok) { // {{{
|
if _, ok := m.Target().Server.(*CLI); m.Assert(ok) { // {{{
|
||||||
m.Optioni("fork", m.Optioni("pos")+1)
|
m.Optioni("fork", m.Optioni("pos")+1)
|
||||||
|
@ -791,7 +791,7 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
"qr_size": &ctx.Config{Name: "qr_size", Value: "256", Help: "生成二维码的图片的大小"},
|
"qr_size": &ctx.Config{Name: "qr_size", Value: "256", Help: "生成二维码的图片的大小"},
|
||||||
|
|
||||||
"dir_name": &ctx.Config{Name: "dir_name(name/tree/path/full)", Value: "name", Help: "dir命令输出文件名的类型, name: 文件名, tree: 带缩进的文件名, path: 相对路径, full: 绝对路径"},
|
"dir_name": &ctx.Config{Name: "dir_name(name/tree/path/full)", Value: "name", Help: "dir命令输出文件名的类型, name: 文件名, tree: 带缩进的文件名, path: 相对路径, full: 绝对路径"},
|
||||||
"dir_info": &ctx.Config{Name: "dir_info(info)", Value: "info", Help: "dir命令输出目录的统计信息, info: 输出统计信息, 否则输出"},
|
"dir_info": &ctx.Config{Name: "dir_info(sizes/lines/files/dirs)", Value: "sizes lines files dirs", Help: "dir命令输出目录的统计信息, info: 输出统计信息, 否则输出"},
|
||||||
"dir_type": &ctx.Config{Name: "dir_type(file/dir)", Value: "file", Help: "dir命令输出的文件类型, file: 只输出普通文件, dir: 只输出目录文件, 否则输出所有文件"},
|
"dir_type": &ctx.Config{Name: "dir_type(file/dir)", Value: "file", Help: "dir命令输出的文件类型, file: 只输出普通文件, dir: 只输出目录文件, 否则输出所有文件"},
|
||||||
"sort_field": &ctx.Config{Name: "sort_field", Value: "line", Help: "表格排序字段"},
|
"sort_field": &ctx.Config{Name: "sort_field", Value: "line", Help: "表格排序字段"},
|
||||||
"sort_order": &ctx.Config{Name: "sort_order(int/int_r/string/string_r/time/time_r)", Value: "int", Help: "表格排序类型"},
|
"sort_order": &ctx.Config{Name: "sort_order(int/int_r/string/string_r/time/time_r)", Value: "int", Help: "表格排序类型"},
|
||||||
@ -1043,12 +1043,11 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
trip = len(wd) + 1
|
trip = len(wd) + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Confx("dir_info") == "info" {
|
info := strings.Split(m.Confx("dir_info"), " ")
|
||||||
m.Option("sizes", 0)
|
for _, v := range info {
|
||||||
m.Option("lines", 0)
|
m.Option(v, 0)
|
||||||
m.Option("files", 0)
|
|
||||||
m.Option("dirs", 0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dir(m, d, 0)
|
dir(m, d, 0)
|
||||||
m.Sort(m.Confx("sort_field"), m.Confx("sort_order"))
|
m.Sort(m.Confx("sort_field"), m.Confx("sort_order"))
|
||||||
m.Table(func(maps map[string]string, list []string, line int) bool {
|
m.Table(func(maps map[string]string, list []string, line int) bool {
|
||||||
@ -1067,11 +1066,8 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
m.Echo("\n")
|
m.Echo("\n")
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
if m.Confx("dir_info") == "info" {
|
for _, v := range info {
|
||||||
m.Echo("sizes: %s\n", m.Option("sizes"))
|
m.Echo("%s: %s\n", v, m.Option(v))
|
||||||
m.Echo("lines: %s\n", m.Option("lines"))
|
|
||||||
m.Echo("files: %s\n", m.Option("files"))
|
|
||||||
m.Echo("dirs: %s\n", m.Option("dirs"))
|
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
}},
|
}},
|
||||||
@ -1128,6 +1124,65 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
m.Echo("%s\n", e)
|
m.Echo("%s\n", e)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
case "csv":
|
||||||
|
cmd := exec.Command("git", "log", "--shortstat", "--pretty=commit: %ad", "--date=format:%Y-%m-%d")
|
||||||
|
if out, e := cmd.CombinedOutput(); e != nil {
|
||||||
|
m.Echo("error: ")
|
||||||
|
m.Echo("%s\n", e)
|
||||||
|
} else {
|
||||||
|
f, e := os.Create(arg[1])
|
||||||
|
m.Assert(e)
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
type stat struct {
|
||||||
|
date string
|
||||||
|
adds int
|
||||||
|
dels int
|
||||||
|
}
|
||||||
|
stats := []*stat{}
|
||||||
|
list := strings.Split(string(out), "commit: ")
|
||||||
|
for _, v := range list {
|
||||||
|
l := strings.Split(v, "\n")
|
||||||
|
if len(l) > 2 {
|
||||||
|
fs := strings.Split(strings.Trim(l[2], " "), ", ")
|
||||||
|
stat := &stat{date: l[0]}
|
||||||
|
if len(fs) > 2 {
|
||||||
|
adds := strings.Split(fs[1], " ")
|
||||||
|
dels := strings.Split(fs[2], " ")
|
||||||
|
a, e := strconv.Atoi(adds[0])
|
||||||
|
m.Assert(e)
|
||||||
|
stat.adds = a
|
||||||
|
d, e := strconv.Atoi(dels[0])
|
||||||
|
m.Assert(e)
|
||||||
|
stat.dels = d
|
||||||
|
} else {
|
||||||
|
adds := strings.Split(fs[1], " ")
|
||||||
|
a, e := strconv.Atoi(adds[0])
|
||||||
|
m.Assert(e)
|
||||||
|
if adds[1] == "insertions(+)" {
|
||||||
|
stat.adds = a
|
||||||
|
} else {
|
||||||
|
stat.dels = a
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stats = append(stats, stat)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(f, "order,date,adds,dels,sum,top,bottom,last\n")
|
||||||
|
l := len(stats)
|
||||||
|
for i := 0; i < l/2; i++ {
|
||||||
|
stats[i], stats[l-i-1] = stats[l-i-1], stats[i]
|
||||||
|
}
|
||||||
|
sum := 0
|
||||||
|
for i, v := range stats {
|
||||||
|
fmt.Fprintf(f, "%d,%s,%d,%d,%d,%d,%d,%d\n", i, v.date, v.adds, v.dels, sum, sum+v.adds, sum-v.dels, sum+v.adds-v.dels)
|
||||||
|
sum += v.adds - v.dels
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
|
||||||
case "log":
|
case "log":
|
||||||
args = append(args, "--color")
|
args = append(args, "--color")
|
||||||
args = append(args, strings.Split(m.Confx("git_log"), " ")...)
|
args = append(args, strings.Split(m.Confx("git_log"), " ")...)
|
||||||
|
@ -161,6 +161,7 @@ func (web *WEB) Spawn(m *ctx.Message, c *ctx.Context, arg ...string) ctx.Server
|
|||||||
|
|
||||||
s := new(WEB)
|
s := new(WEB)
|
||||||
s.Context = c
|
s.Context = c
|
||||||
|
s.cookie = web.cookie
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +307,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
} // }}}
|
} // }}}
|
||||||
}},
|
}},
|
||||||
"cookie": &ctx.Command{
|
"cookie": &ctx.Command{
|
||||||
Name: "cookie [name [value]]",
|
Name: "cookie [create]|[name [value]]",
|
||||||
Help: "读写请求的Cookie, name: 变量名, value: 变量值",
|
Help: "读写请求的Cookie, name: 变量名, value: 变量值",
|
||||||
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
if web, ok := m.Target().Server.(*WEB); m.Assert(ok) { // {{{
|
if web, ok := m.Target().Server.(*WEB); m.Assert(ok) { // {{{
|
||||||
@ -316,6 +317,10 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
m.Echo("%s: %v\n", k, v.Value)
|
m.Echo("%s: %v\n", k, v.Value)
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
|
if arg[0] == "create" {
|
||||||
|
web.cookie = make(map[string]*http.Cookie)
|
||||||
|
break
|
||||||
|
}
|
||||||
if v, ok := web.cookie[arg[0]]; ok {
|
if v, ok := web.cookie[arg[0]]; ok {
|
||||||
m.Echo("%s", v.Value)
|
m.Echo("%s", v.Value)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user