1
0
forked from x/icebergs

opt command name

This commit is contained in:
shylinux 2020-04-13 21:27:54 +08:00
parent 192bd7cdb2
commit dd3b68d32c
19 changed files with 671 additions and 734 deletions

View File

@ -69,6 +69,7 @@ var Index = &ice.Context{Name: "cli", Help: "命令模块",
}}, }},
ice.CLI_RUNTIME: {Name: "runtime", Help: "运行环境", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.CLI_RUNTIME: {Name: "runtime", Help: "运行环境", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmdy(ice.CTX_CONFIG, ice.CLI_RUNTIME, arg)
}}, }},
ice.CLI_SYSTEM: {Name: "system", Help: "系统命令", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { ice.CLI_SYSTEM: {Name: "system", Help: "系统命令", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
cmd := exec.Command(arg[0], arg[1:]...) cmd := exec.Command(arg[0], arg[1:]...)

View File

@ -110,19 +110,27 @@ var Index = &ice.Context{Name: "ctx", Help: "配置模块",
button := false button := false
for i, v := range list { for i, v := range list {
if i > 0 { if i > 0 {
ls := kit.Split(v, ":=") switch ls := kit.Split(v, ":="); ls[0] {
switch ls[0] { case "[", "]":
case "auto": case "auto":
cmd.List = append(cmd.List, kit.List(kit.MDB_INPUT, "button", "name", "查看", "value", "auto")...) cmd.List = append(cmd.List, kit.List(kit.MDB_INPUT, "button", "name", "查看", "value", "auto")...)
cmd.List = append(cmd.List, kit.List(kit.MDB_INPUT, "button", "name", "返回", "value", "Last")...) cmd.List = append(cmd.List, kit.List(kit.MDB_INPUT, "button", "name", "返回", "value", "Last")...)
button = true button = true
default: default:
if len(ls) > 1 && ls[1] == "button" { kind, value := "text", ""
if len(ls) == 3 {
kind, value = ls[1], ls[2]
} else if len(ls) == 2 {
if strings.Contains(v, "=") {
value = ls[1]
} else {
kind = ls[1]
}
}
if kind == "button" {
button = true button = true
} }
cmd.List = append(cmd.List, kit.List( cmd.List = append(cmd.List, kit.List(kit.MDB_INPUT, kind, "name", ls[0], "value", value)...)
kit.MDB_INPUT, kit.Select("text", ls, 1), "name", ls[0], "value", kit.Select("", ls, 2),
)...)
} }
} }
} }

View File

@ -357,6 +357,11 @@ var Index = &ice.Context{Name: "ssh", Help: "终端模块",
} }
}) })
}}, }},
"what": {Name: "what", Help: "上位机", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
ls := kit.Split("window:=auto", " ", ":=")
m.Echo("%v %v", len(ls), ls)
}},
}, },
} }

View File

@ -483,7 +483,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
ice.WEB_SHARE: {Name: "share", Help: "共享链", Value: kit.Data("index", "usr/volcanos/share.html", "template", share_template)}, ice.WEB_SHARE: {Name: "share", Help: "共享链", Value: kit.Data("index", "usr/volcanos/share.html", "template", share_template)},
ice.WEB_ROUTE: {Name: "route", Help: "路由", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME)}, ice.WEB_ROUTE: {Name: "route", Help: "路由", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME)},
ice.WEB_PROXY: {Name: "proxy", Help: "代理", Value: kit.Data()}, ice.WEB_PROXY: {Name: "proxy", Help: "代理", Value: kit.Data(kit.MDB_SHORT, "proxy")},
ice.WEB_GROUP: {Name: "group", Help: "分组", Value: kit.Data(kit.MDB_SHORT, "group")}, ice.WEB_GROUP: {Name: "group", Help: "分组", Value: kit.Data(kit.MDB_SHORT, "group")},
ice.WEB_LABEL: {Name: "label", Help: "标签", Value: kit.Data(kit.MDB_SHORT, "label")}, ice.WEB_LABEL: {Name: "label", Help: "标签", Value: kit.Data(kit.MDB_SHORT, "label")},
}, },
@ -508,8 +508,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
m.Conf(ice.WEB_SHARE, "meta.template", share_template) m.Conf(ice.WEB_SHARE, "meta.template", share_template)
}}, }},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Save(ice.WEB_SPIDE, ice.WEB_SERVE, m.Save(ice.WEB_SPIDE, ice.WEB_SERVE, ice.WEB_GROUP, ice.WEB_LABEL,
ice.WEB_GROUP, ice.WEB_LABEL,
ice.WEB_FAVOR, ice.WEB_CACHE, ice.WEB_STORY, ice.WEB_SHARE, ice.WEB_FAVOR, ice.WEB_CACHE, ice.WEB_STORY, ice.WEB_SHARE,
) )
@ -521,12 +520,8 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
}) })
}}, }},
ice.WEB_SPIDE: {Name: "spide name [msg|raw|cache] POST|GET url [json|form|part|file|data] arg...", Help: "蜘蛛侠", List: kit.List( ice.WEB_SPIDE: {Name: "spide name=auto [action:select=msg|raw|cache] [method:select=POST|GET] url [format:select=json|form|part|data|file] arg... auto", Help: "蜘蛛侠", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "name", if len(arg) == 0 || arg[0] == "" {
kit.MDB_INPUT, "button", "value", "查看", "action", "auto",
kit.MDB_INPUT, "button", "value", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 0 {
// 爬虫列表 // 爬虫列表
m.Richs(ice.WEB_SPIDE, nil, "*", func(key string, value map[string]interface{}) { m.Richs(ice.WEB_SPIDE, nil, "*", func(key string, value map[string]interface{}) {
m.Push(key, value["client"], []string{"name", "share", "login", "method", "url"}) m.Push(key, value["client"], []string{"name", "share", "login", "method", "url"})
@ -534,7 +529,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
m.Sort("name") m.Sort("name")
return return
} }
if len(arg) == 1 { if len(arg) == 1 || len(arg) > 3 && arg[3] == "" {
// 爬虫详情 // 爬虫详情
m.Richs(ice.WEB_SPIDE, nil, arg[0], func(key string, value map[string]interface{}) { m.Richs(ice.WEB_SPIDE, nil, arg[0], func(key string, value map[string]interface{}) {
m.Push("detail", value) m.Push("detail", value)
@ -625,8 +620,6 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
body, ok := m.Optionv("body").(io.Reader) body, ok := m.Optionv("body").(io.Reader)
if !ok && len(arg) > 0 && method != "GET" { if !ok && len(arg) > 0 && method != "GET" {
switch arg[0] { switch arg[0] {
case "data":
body, arg = bytes.NewBufferString(arg[1]), arg[2:]
case "file": case "file":
if f, e := os.Open(arg[1]); m.Warn(e != nil, "%s", e) { if f, e := os.Open(arg[1]); m.Warn(e != nil, "%s", e) {
return return
@ -634,6 +627,8 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
defer f.Close() defer f.Close()
body, arg = f, arg[2:] body, arg = f, arg[2:]
} }
case "data":
body, arg = bytes.NewBufferString(arg[1]), arg[2:]
case "part": case "part":
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
mp := multipart.NewWriter(buf) mp := multipart.NewWriter(buf)
@ -782,10 +777,8 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
m.Cmd(ice.WEB_SPACE, "connect", k) m.Cmd(ice.WEB_SPACE, "connect", k)
} }
}}, }},
ice.WEB_SPACE: {Name: "space", Help: "空间站", Meta: kit.Dict("exports", []string{"pod", "name"}), List: kit.List( ice.WEB_SPACE: {Name: "space name auto", Help: "空间站", Meta: kit.Dict(
kit.MDB_INPUT, "text", "name", "name", "exports", []string{"pod", "name"},
kit.MDB_INPUT, "button", "value", "查看", "action", "auto",
kit.MDB_INPUT, "button", "value", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 0 { if len(arg) == 0 {
// 空间列表 // 空间列表
@ -901,13 +894,8 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
}) == nil, "not found %s", arg[0]) }) == nil, "not found %s", arg[0])
} }
}}, }},
ice.WEB_DREAM: {Name: "dream", Help: "梦想家", Meta: kit.Dict( ice.WEB_DREAM: {Name: "dream name auto", Help: "梦想家", Meta: kit.Dict(
"exports", []string{"you", "name"}, "exports", []string{"you", "name"}, "detail", []interface{}{"启动", "停止"},
"detail", []interface{}{"启动", "停止"},
), List: kit.List(
kit.MDB_INPUT, "text", "value", "", "name", "name",
kit.MDB_INPUT, "button", "value", "创建", "action", "auto",
kit.MDB_INPUT, "button", "value", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 1 && arg[0] == "action" { if len(arg) > 1 && arg[0] == "action" {
switch arg[1] { switch arg[1] {
@ -962,16 +950,8 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
m.Cmdy("nfs.dir", p) m.Cmdy("nfs.dir", p)
}}, }},
ice.WEB_FAVOR: {Name: "favor [path [type name [text [key value]....]]", Help: "收藏夹", Meta: kit.Dict( ice.WEB_FAVOR: {Name: "favor favor=auto id=auto auto", Help: "收藏夹", Meta: kit.Dict(
"exports", []string{"hot", "favor"}, "exports", []string{"hot", "favor"}, "detail", []string{"编辑", "收藏", "收录", "导出", "删除"},
"detail", []string{"编辑", "收藏", "收录", "导出", "删除"},
), List: kit.List(
kit.MDB_INPUT, "text", "name", "favor", "action", "auto",
kit.MDB_INPUT, "text", "name", "id", "action", "auto",
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
kit.MDB_INPUT, "button", "name", "渲染",
kit.MDB_INPUT, "button", "name", "回放",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
switch m.Option("_action") { switch m.Option("_action") {
case "渲染": case "渲染":
@ -1322,12 +1302,8 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
m.Echo(arg[2]) m.Echo(arg[2])
} }
}}, }},
ice.WEB_STORY: {Name: "story", Help: "故事会", Meta: kit.Dict("exports", []string{"top", "story"}, ice.WEB_STORY: {Name: "story story=auto key=auto auto", Help: "故事会", Meta: kit.Dict(
"detail", []string{"共享", "更新", "推送"}), List: kit.List( "exports", []string{"top", "story"}, "detail", []string{"共享", "更新", "推送"},
kit.MDB_INPUT, "text", "name", "story", "action", "auto",
kit.MDB_INPUT, "text", "name", "list", "action", "auto",
kit.MDB_INPUT, "button", "value", "查看", "action", "auto",
kit.MDB_INPUT, "button", "value", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 1 && arg[0] == "action" { if len(arg) > 1 && arg[0] == "action" {
story, list := m.Option("story"), m.Option("list") story, list := m.Option("story"), m.Option("list")
@ -1651,8 +1627,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
m.Richs(ice.WEB_STORY, nil, list, func(key string, value map[string]interface{}) { m.Richs(ice.WEB_STORY, nil, list, func(key string, value map[string]interface{}) {
// 直连节点 // 直连节点
m.Push("list", key) m.Push(key, value, []string{"time", "key", "count", "scene", "story"})
m.Push(list, value, []string{"time", "count", "scene", "story"})
m.Richs(ice.WEB_CACHE, nil, value["data"], func(key string, value map[string]interface{}) { m.Richs(ice.WEB_CACHE, nil, value["data"], func(key string, value map[string]interface{}) {
m.Push("drama", value["text"]) m.Push("drama", value["text"])
m.Push("data", key) m.Push("data", key)
@ -1661,8 +1636,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
kit.Fetch(value["list"], func(key string, val string) { kit.Fetch(value["list"], func(key string, val string) {
m.Richs(ice.WEB_STORY, nil, val, func(key string, value map[string]interface{}) { m.Richs(ice.WEB_STORY, nil, val, func(key string, value map[string]interface{}) {
// 复合节点 // 复合节点
m.Push("list", key) m.Push(key, value, []string{"time", "key", "count", "scene", "story"})
m.Push(list, value, []string{"time", "count", "scene", "story"})
m.Richs(ice.WEB_CACHE, nil, value["data"], func(key string, value map[string]interface{}) { m.Richs(ice.WEB_CACHE, nil, value["data"], func(key string, value map[string]interface{}) {
m.Push("drama", value["text"]) m.Push("drama", value["text"])
m.Push("data", key) m.Push("data", key)
@ -1691,11 +1665,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
}) })
} }
}}, }},
ice.WEB_SHARE: {Name: "share", Help: "共享链", List: kit.List( ice.WEB_SHARE: {Name: "share share auto", Help: "共享链", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "share", "action", "auto",
kit.MDB_INPUT, "button", "value", "查看", "action", "auto",
kit.MDB_INPUT, "button", "value", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 0 { if len(arg) == 0 {
// 共享列表 // 共享列表
m.Grows(ice.WEB_SHARE, nil, "", "", func(index int, value map[string]interface{}) { m.Grows(ice.WEB_SHARE, nil, "", "", func(index int, value map[string]interface{}) {

View File

@ -189,14 +189,14 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
} }
}}, }},
"search": {Name: "search label:text=some word:text=启动流程 auto", Help: "搜索引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "search": {Name: "search label=some word=启动流程 auto", Help: "搜索引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) < 2 { if len(arg) < 2 {
m.Cmdy(ice.WEB_LABEL, arg) m.Cmdy(ice.WEB_LABEL, arg)
return return
} }
m.Cmdy(ice.WEB_LABEL, arg[0], "*", "favor", "search", arg[1:]) m.Cmdy(ice.WEB_LABEL, arg[0], "*", "favor", "search", arg[1:])
}}, }},
"commend": {Name: "commend label:text=some word:text=请求响应 auto", Help: "推荐引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "commend": {Name: "commend label=some word=请求响应 auto", Help: "推荐引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) < 2 { if len(arg) < 2 {
m.Cmdy(ice.WEB_LABEL, arg) m.Cmdy(ice.WEB_LABEL, arg)
return return

View File

@ -138,9 +138,9 @@ var Index = &ice.Context{Name: "code", Help: "编程中心",
} }
}}, }},
"login": {Name: "login", Help: "登录", Meta: kit.Dict( "login": {Name: "login key", Help: "登录", Meta: kit.Dict(
"detail", []string{"编辑", "删除", "清理", "清空"}, "detail", []string{"编辑", "删除", "清理", "清空"},
), List: ice.ListLook("key"), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 0 && arg[0] == "action" { if len(arg) > 0 && arg[0] == "action" {
switch arg[1] { switch arg[1] {
case "modify", "编辑": case "modify", "编辑":

View File

@ -6,7 +6,6 @@ import (
"github.com/shylinux/toolkits" "github.com/shylinux/toolkits"
"encoding/csv" "encoding/csv"
"fmt"
"strconv" "strconv"
"strings" "strings"
) )
@ -39,8 +38,6 @@ func input(m *ice.Message, arg ...string) bool {
var Index = &ice.Context{Name: "mall", Help: "贸易中心", var Index = &ice.Context{Name: "mall", Help: "贸易中心",
Caches: map[string]*ice.Cache{}, Caches: map[string]*ice.Cache{},
Configs: map[string]*ice.Config{ Configs: map[string]*ice.Config{
"railway": {Name: "railway", Help: "12306", Value: kit.Data("site", "https://kyfw.12306.cn")},
"asset": {Name: "asset", Help: "资产", Value: kit.Data(kit.MDB_SHORT, "account", "site", kit.Dict( "asset": {Name: "asset", Help: "资产", Value: kit.Data(kit.MDB_SHORT, "account", "site", kit.Dict(
"公积金", "https://grwsyw.gjj.beijing.gov.cn/ish/flow/menu/PPLGRZH0102?_r=0.6644871172745264", "公积金", "https://grwsyw.gjj.beijing.gov.cn/ish/flow/menu/PPLGRZH0102?_r=0.6644871172745264",
"社保", "http://fuwu.rsj.beijing.gov.cn/csibiz/indinfo/index.jsp", "社保", "http://fuwu.rsj.beijing.gov.cn/csibiz/indinfo/index.jsp",
@ -52,21 +49,13 @@ var Index = &ice.Context{Name: "mall", Help: "贸易中心",
Commands: map[string]*ice.Command{ Commands: map[string]*ice.Command{
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Load() m.Load()
m.Cmd(ice.WEB_SPIDE, "add", "12306", m.Conf("railway", "meta.site"))
}}, }},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Save("asset", "railway") m.Save("asset")
}}, }},
"spend": {Name: "spend", Help: "支出", List: kit.List( "spend": {Name: "spend account=@key to=@key name=@key 记录:button text:textarea value=@key time=@date",
kit.MDB_INPUT, "text", "name", "account", "figure", "key", Help: "支出", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "to", "figure", "key",
kit.MDB_INPUT, "text", "name", "name", "figure", "key",
kit.MDB_INPUT, "button", "name", "记录",
kit.MDB_INPUT, "textarea", "name", "text", "figure", "key",
kit.MDB_INPUT, "text", "name", "value", "figure", "key",
kit.MDB_INPUT, "text", "name", "time", "figure", "date",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if input(m, arg...) { if input(m, arg...) {
// 输入补全 // 输入补全
return return
@ -83,15 +72,8 @@ var Index = &ice.Context{Name: "mall", Help: "贸易中心",
m.Cmdy("asset", arg[1], "", "支出", arg[2], arg[3], -amount, "time", arg[5:]) m.Cmdy("asset", arg[1], "", "支出", arg[2], arg[3], -amount, "time", arg[5:])
m.Cmdy("asset", "流水", "", "支出", arg[2], arg[3], -amount, "time", arg[5:]) m.Cmdy("asset", "流水", "", "支出", arg[2], arg[3], -amount, "time", arg[5:])
}}, }},
"trans": {Name: "trans", Help: "转账", List: kit.List( "trans": {Name: "trans account=@key to=@key name=@key 记录:button text:textarea value=@key time=@date",
kit.MDB_INPUT, "text", "name", "account", "figure", "key", Help: "转账", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "to", "figure", "key",
kit.MDB_INPUT, "text", "name", "name", "figure", "key",
kit.MDB_INPUT, "button", "name", "记录",
kit.MDB_INPUT, "textarea", "name", "text", "figure", "key",
kit.MDB_INPUT, "text", "name", "value", "figure", "key",
kit.MDB_INPUT, "text", "name", "time", "figure", "date",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if input(m, arg...) { if input(m, arg...) {
// 输入补全 // 输入补全
return return
@ -108,14 +90,8 @@ var Index = &ice.Context{Name: "mall", Help: "贸易中心",
m.Cmd("asset", "流水", "", "转出", arg[2], arg[3], -amount, "time", arg[5:]) m.Cmd("asset", "流水", "", "转出", arg[2], arg[3], -amount, "time", arg[5:])
m.Cmd("asset", "流水", "", "转入", arg[2], arg[3], amount, "time", arg[5:]) m.Cmd("asset", "流水", "", "转入", arg[2], arg[3], amount, "time", arg[5:])
}}, }},
"bonus": {Name: "bonus", Help: "收入", List: kit.List( "bonus": {Name: "bonus account=@key name=@key value=@key 记录:button text:textarea time=@date",
kit.MDB_INPUT, "text", "name", "account", "figure", "key", Help: "收入", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "name", "figure", "key",
kit.MDB_INPUT, "text", "name", "value", "figure", "key",
kit.MDB_INPUT, "button", "name", "记录",
kit.MDB_INPUT, "textarea", "name", "text", "figure", "key",
kit.MDB_INPUT, "text", "name", "time", "figure", "date",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if input(m, arg...) { if input(m, arg...) {
// 输入补全 // 输入补全
return return
@ -130,13 +106,8 @@ var Index = &ice.Context{Name: "mall", Help: "贸易中心",
m.Cmdy("asset", arg[0], "", "收入", arg[1], arg[3], amount, "time", arg[4:]) m.Cmdy("asset", arg[0], "", "收入", arg[1], arg[3], amount, "time", arg[4:])
m.Cmdy("asset", "流水", "", "收入", arg[1], arg[3], amount, "time", arg[4:]) m.Cmdy("asset", "流水", "", "收入", arg[1], arg[3], amount, "time", arg[4:])
}}, }},
"month": {Name: "month", Help: "工资", List: kit.List( "month": {Name: "month month value value 计算:button 记录:button",
kit.MDB_INPUT, "text", "name", "month", Help: "工资", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "value", "figure", "key",
kit.MDB_INPUT, "text", "name", "value", "figure", "key",
kit.MDB_INPUT, "button", "name", "计算",
kit.MDB_INPUT, "button", "name", "记录",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
// 输入补全 // 输入补全
if input(m, arg...) { if input(m, arg...) {
return return
@ -282,16 +253,8 @@ var Index = &ice.Context{Name: "mall", Help: "贸易中心",
m.Cmd("trans", "工资", "个税", tax, arg[0]) m.Cmd("trans", "工资", "个税", tax, arg[0])
} }
}}, }},
"asset": {Name: "asset account type name value", Help: []string{"资产", "asset": {Name: "asset account=auto id=auto auto",
"action save file [account [key value]]", Help: "资产", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
"action load file [account]",
}, List: kit.List(
kit.MDB_INPUT, "text", "name", "account", "action", "auto",
kit.MDB_INPUT, "text", "name", "id", "action", "auto",
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
kit.MDB_INPUT, "button", "name", "保存",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if m.Option("_action") == "保存" { if m.Option("_action") == "保存" {
arg = []string{"action", "save"} arg = []string{"action", "save"}
} }
@ -470,77 +433,6 @@ var Index = &ice.Context{Name: "mall", Help: "贸易中心",
} }
}) })
}}, }},
"railway": &ice.Command{Name: "railway", Help: "12306", List: kit.List(
kit.MDB_INPUT, "text", "name", "date", "figure", "date",
kit.MDB_INPUT, "text", "name", "from", "value", "北京", "figure", "city",
kit.MDB_INPUT, "text", "name", "to", "value", "曲阜", "figure", "city",
kit.MDB_INPUT, "button", "name", "查询",
), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
if !m.Confs("railway", "meta.place") {
list := strings.Split(strings.TrimPrefix(m.Cmdx(ice.WEB_SPIDE, "12306", "raw", "GET", "/otn/resources/js/framework/station_name.js?station_version=1.9090"), "var statuion_names ='"), "|")
for i := 0; i < len(list)-5; i += 5 {
m.Conf("railway", kit.Keys("meta.place", list[i+1]), list[i+2])
}
}
date := strings.Split(m.Time("24h"), " ")[0]
if len(arg) > 0 {
date, arg = arg[0], arg[1:]
}
date = strings.Split(date, " ")[0]
from := "北京"
if len(arg) > 0 {
from, arg = arg[0], arg[1:]
}
from_code := m.Conf("railway", kit.Keys("meta.place", from))
to := "曲阜"
if len(arg) > 0 {
to, arg = arg[0], arg[1:]
}
to_code := m.Conf("railway", kit.Keys("meta.place", to))
m.Echo("%s->%s %s\n", from, to, date)
if len(arg) > 0 {
m.Cmdy(ice.WEB_SPIDE, "12306", "raw", "GET", fmt.Sprintf("/otn/czxx/queryByTrainNo?train_no=%s&from_station_telecode=%s&to_station_telecode=%s&depart_date=%s",
arg[0], from_code, to_code, date))
return
}
m.Cmd(ice.WEB_SPIDE, "12306", "GET", fmt.Sprintf("/otn/leftTicket/init?linktypeid=dc&fs=%s,%s&ts=%s,%s&date=%s&flag=N,N,Y",
from, from_code, to, to_code, date))
m.Cmd(ice.WEB_SPIDE, "12306", "GET", fmt.Sprintf("/otn/leftTicket/queryZ?leftTicketDTO.train_date=%s&leftTicketDTO.from_station=%s&leftTicketDTO.to_station=%s&purpose_codes=ADULT",
date, from_code, to_code)).Table(func(index int, value map[string]string, head []string) {
kit.Fetch(kit.Value(kit.UnMarshal(value["data"]), "result"), func(index int, value string) {
fields := strings.Split(value, "|")
m.Push("车次", fields[3])
m.Push("出发", fields[8])
m.Push("到站", fields[9])
m.Push("时长", fields[10])
m.Push("二等座", fields[30])
m.Push("一等座", fields[31])
})
})
}},
"passcode": &ice.Command{Name: "passcode", Help: "passcode", Meta: kit.Dict("active", "mall/input"), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
prefix := []string{ice.WEB_SPIDE, "12306"}
if len(arg) == 0 {
m.Cmd(prefix, "raw", "/passport/web/auth/uamtk-static", "form", "appid", "otn")
m.Cmd(prefix, "raw", "GET", "/otn/HttpZF/GetJS")
m.Cmd(prefix, "raw", "/otn/login/conf")
m.Cmdy(prefix, "GET", fmt.Sprintf("/passport/captcha/captcha-image64?login_site=E&module=login&rand=sjrand"))
return
}
switch arg[0] {
case "check":
m.Cmdy(prefix, "GET", fmt.Sprintf("/passport/captcha/captcha-check?login_site=E&rand=sjrand&answer=%s", arg[1]))
case "login":
m.Cmdy(prefix, "raw", "/passport/web/login", "form", "username", arg[1], "password", arg[2], "answer", arg[3], "appid", "otn")
}
}},
}, },
} }

View File

@ -35,8 +35,7 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
Configs: map[string]*ice.Config{ Configs: map[string]*ice.Config{
"task": {Name: "task", Help: "任务", Value: kit.Data(kit.MDB_SHORT, "zone")}, "task": {Name: "task", Help: "任务", Value: kit.Data(kit.MDB_SHORT, "zone")},
"plan": {Name: "plan", Help: "计划", Value: kit.Data(kit.MDB_SHORT, "zone", "plan": {Name: "plan", Help: "计划", Value: kit.Data(kit.MDB_SHORT, "zone",
"head", []interface{}{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, "head", []interface{}{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, "template", kit.Dict(
"template", kit.Dict(
"day", `<div class="task {{.status}}" data-zone="%s" data-id="{{.id}}" data-begin_time="{{.begin_time}}">{{.status}} {{.name}}: {{.text}}</div>`, "day", `<div class="task {{.status}}" data-zone="%s" data-id="{{.id}}" data-begin_time="{{.begin_time}}">{{.status}} {{.name}}: {{.text}}</div>`,
"week", `<div class="task {{.status}}" data-zone="%s" data-id="{{.id}}" data-begin_time="{{.begin_time}}" title="{{.text}}">{{.name}}</div>`, "week", `<div class="task {{.status}}" data-zone="%s" data-id="{{.id}}" data-begin_time="{{.begin_time}}" title="{{.text}}">{{.name}}</div>`,
"month", `<div class="task {{.status}}" data-zone="%s" data-id="{{.id}}" data-begin_time="{{.begin_time}}" title="{{.text}}">{{.name}}</div>`, "month", `<div class="task {{.status}}" data-zone="%s" data-id="{{.id}}" data-begin_time="{{.begin_time}}" title="{{.text}}">{{.name}}</div>`,
@ -52,13 +51,7 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
m.Save("task") m.Save("task")
}}, }},
"task": {Name: "task [zone [id [type [name [text args...]]]]]", Help: "任务", List: kit.List( "task": {Name: "task [zone=auto [id=auto]] auto", Help: "任务", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "zone", "action", "auto",
kit.MDB_INPUT, "text", "name", "id", "action", "auto",
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
kit.MDB_INPUT, "button", "name", "保存",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if m.Option("_action") == "保存" { if m.Option("_action") == "保存" {
arg = []string{"action", "export"} arg = []string{"action", "export"}
} }
@ -145,42 +138,26 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
return return
} }
if len(arg) < 5 {
m.Richs(cmd, nil, kit.Select("*", arg, 0), func(key string, value map[string]interface{}) {
if len(arg) == 0 { if len(arg) == 0 {
// 分类列表 // 分类列表
m.Richs(cmd, nil, "*", func(key string, value map[string]interface{}) {
m.Push(key, value["meta"], []string{"time", "count", "zone"}) m.Push(key, value["meta"], []string{"time", "count", "zone"})
})
return return
} }
if m.Richs(cmd, nil, arg[0], nil) == nil {
// 添加分类
m.Rich(cmd, nil, kit.Data("zone", arg[0]))
m.Log(ice.LOG_CREATE, "zone: %s", arg[0])
}
field := []string{"begin_time", "id", "status", "type", "name", "text"} field := []string{"begin_time", "id", "status", "type", "name", "text"}
m.Richs(cmd, nil, arg[0], func(key string, value map[string]interface{}) {
if len(arg) == 1 { if len(arg) == 1 {
// 任务列表 // 任务列表
m.Grows(cmd, kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) { m.Grows(cmd, kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
m.Push("", value, field) m.Push("", value, field)
}) })
m.Sort("time", "time_r") } else if len(arg) == 2 {
return
}
if len(arg) == 2 {
// 任务详情 // 任务详情
m.Grows(cmd, kit.Keys("hash", key), "id", arg[1], func(index int, value map[string]interface{}) { m.Grows(cmd, kit.Keys("hash", key), "id", arg[1], func(index int, value map[string]interface{}) {
m.Push("detail", value) m.Push("detail", value)
}) })
m.Sort("time", "time_r") } else {
return
}
if len(arg) < 5 {
// 任务查询
name, value := "type", arg[2] name, value := "type", arg[2]
switch len(arg) { switch len(arg) {
case 3: case 3:
@ -193,10 +170,19 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
m.Grows(cmd, kit.Keys("hash", key), name, value, func(index int, value map[string]interface{}) { m.Grows(cmd, kit.Keys("hash", key), name, value, func(index int, value map[string]interface{}) {
m.Push("", value, field) m.Push("", value, field)
}) })
}
m.Sort("time", "time_r") m.Sort("time", "time_r")
})
return return
} }
if m.Richs(cmd, nil, arg[0], nil) == nil {
// 添加分类
m.Rich(cmd, nil, kit.Data("zone", arg[0]))
m.Log(ice.LOG_CREATE, "zone: %s", arg[0])
}
m.Richs(cmd, nil, arg[0], func(key string, value map[string]interface{}) {
// 词汇统计 // 词汇统计
web.Count(m, cmd, "meta.word.type", arg[2]) web.Count(m, cmd, "meta.word.type", arg[2])
web.Count(m, cmd, "meta.word.name", arg[3]) web.Count(m, cmd, "meta.word.name", arg[3])
@ -225,13 +211,8 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
m.Echo("%s: %d", kit.Value(value, "meta.zone"), n) m.Echo("%s: %d", kit.Value(value, "meta.zone"), n)
}) })
}}, }},
"plan": {Name: "plan day|week|month|year", Help: "计划", Meta: kit.Dict( "plan": {Name: "plan scale:select=day|week|month|year begin_time=@date end_time=@date auto", Help: "计划", Meta: kit.Dict(
"display", "team/plan", "detail", []string{"process", "finish", "cancel"}, "display", "team/plan", "detail", []string{"process", "finish", "cancel"},
), List: kit.List(
kit.MDB_INPUT, "select", "name", "scale", "value", "day", "values", []string{"day", "week", "month", "months", "year", "long"}, "action", "auto",
kit.MDB_INPUT, "text", "name", "begin_time", "figure", "date", "action", "auto",
kit.MDB_INPUT, "text", "name", "end_time", "figure", "date", "action", "auto",
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
// 起始日期 // 起始日期
first := time.Now() first := time.Now()
@ -423,11 +404,7 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
m.Sort("year", "int") m.Sort("year", "int")
} }
}}, }},
"stat": {Name: "stat", Help: "统计", List: kit.List( "stat": {Name: "stat begin_time=@date end_time=@date auto", Help: "统计", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
kit.MDB_INPUT, "text", "name", "begin_time", "figure", "date", "action", "auto",
kit.MDB_INPUT, "text", "name", "end_time", "figure", "date", "action", "auto",
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
begin_time := kit.Time(kit.Select("1990-07-30", arg, 0)) begin_time := kit.Time(kit.Select("1990-07-30", arg, 0))
end_time := kit.Time(kit.Select("1990-07-30", arg, 1)) end_time := kit.Time(kit.Select("1990-07-30", arg, 1))
now_time := kit.Time(m.Time()) now_time := kit.Time(m.Time())
@ -473,14 +450,7 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
m.Push("max", kit.FmtTime(int64(stat["max"])*int64(time.Second))) m.Push("max", kit.FmtTime(int64(stat["max"])*int64(time.Second)))
}) })
}}, }},
"miss": {Name: "miss zone type name text", Help: "任务", List: kit.List( "miss": {Name: "miss zone=@key type=@key name=@key 添加:button text:textarea @begin_time=@date", Help: "任务", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
kit.MDB_INPUT, "text", "name", "zone", "figure", "key", "action", "auto",
kit.MDB_INPUT, "text", "name", "type", "figure", "key",
kit.MDB_INPUT, "text", "name", "name", "figure", "key",
kit.MDB_INPUT, "button", "name", "添加",
kit.MDB_INPUT, "textarea", "name", "text",
kit.MDB_INPUT, "text", "name", "begin_time", "figure", "date", "position", "opts",
), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
if len(arg) > 0 && arg[0] == "action" { if len(arg) > 0 && arg[0] == "action" {
switch arg[1] { switch arg[1] {
case "input": case "input":

View File

@ -1,15 +1,12 @@
package wiki package wiki
import ( import (
"github.com/gomarkdown/markdown"
"github.com/shylinux/icebergs" "github.com/shylinux/icebergs"
_ "github.com/shylinux/icebergs/base" _ "github.com/shylinux/icebergs/base"
"github.com/shylinux/icebergs/base/web" "github.com/shylinux/icebergs/base/web"
"github.com/shylinux/toolkits" "github.com/shylinux/toolkits"
"fmt" "fmt"
"io/ioutil"
"math/rand"
"os" "os"
"path" "path"
"strings" "strings"
@ -36,10 +33,6 @@ func reply(m *ice.Message, cmd string, arg ...string) bool {
var Index = &ice.Context{Name: "wiki", Help: "文档中心", var Index = &ice.Context{Name: "wiki", Help: "文档中心",
Caches: map[string]*ice.Cache{}, Caches: map[string]*ice.Cache{},
Configs: map[string]*ice.Config{ Configs: map[string]*ice.Config{
"note": {Name: "note", Help: "笔记", Value: kit.Data(
"path", "", "head", "time size line path",
)},
"title": {Name: "title", Help: "标题", Value: kit.Data("template", title)}, "title": {Name: "title", Help: "标题", Value: kit.Data("template", title)},
"brief": {Name: "brief", Help: "摘要", Value: kit.Data("template", brief)}, "brief": {Name: "brief", Help: "摘要", Value: kit.Data("template", brief)},
"refer": {Name: "refer", Help: "参考", Value: kit.Data("template", refer)}, "refer": {Name: "refer", Help: "参考", Value: kit.Data("template", refer)},
@ -47,7 +40,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
"local": {Name: "local", Help: "文件", Value: kit.Data("template", local)}, "local": {Name: "local", Help: "文件", Value: kit.Data("template", local)},
"shell": {Name: "shell", Help: "命令", Value: kit.Data("template", shell)}, "shell": {Name: "shell", Help: "命令", Value: kit.Data("template", shell)},
"field": {Name: "shell", Help: "命令", Value: kit.Data("template", field, "field": {Name: "field", Help: "插件", Value: kit.Data("template", field,
"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",
@ -62,7 +55,9 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
"stack": {Name: "stack", Help: "结构", Value: kit.Data("template", stack)}, "stack": {Name: "stack", Help: "结构", Value: kit.Data("template", stack)},
"chart": {Name: "chart", Help: "绘图", Value: kit.Data("template", prefix, "suffix", `</svg>`)}, "chart": {Name: "chart", Help: "绘图", Value: kit.Data("template", prefix, "suffix", `</svg>`)},
"draw": {Name: "draw", Help: "思维导图", Value: kit.Data(kit.MDB_SHORT, "name", "path", "", "regs", ".*\\.svg", "prefix", `<svg vertion="1.1" xmlns="http://www.w3.org/2000/svg" width="%v" height="%v">`, "suffix", `</svg>`)}, "draw": {Name: "draw", Help: "思维导图", Value: kit.Data(kit.MDB_SHORT, "name", "path", "", "regs", ".*\\.svg",
"prefix", `<svg vertion="1.1" xmlns="http://www.w3.org/2000/svg" width="%v" height="%v">`, "suffix", `</svg>`,
)},
"data": {Name: "data", Help: "数据表格", Value: kit.Data(kit.MDB_SHORT, "name", "path", "", "regs", ".*\\.csv")}, "data": {Name: "data", Help: "数据表格", Value: kit.Data(kit.MDB_SHORT, "name", "path", "", "regs", ".*\\.csv")},
"word": {Name: "word", Help: "语言文字", Value: kit.Data(kit.MDB_SHORT, "name", "path", "", "regs", ".*\\.shy", "word": {Name: "word", Help: "语言文字", Value: kit.Data(kit.MDB_SHORT, "name", "path", "", "regs", ".*\\.shy",
"alias", map[string]interface{}{ "alias", map[string]interface{}{
@ -86,28 +81,6 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
m.Save("feel") m.Save("feel")
}}, }},
"note": {Name: "note file", Help: "文档", Meta: kit.Dict("display", "inner"), List: kit.List(
kit.MDB_INPUT, "text", "name", "path", "value", "README.md", "action", "auto",
kit.MDB_INPUT, "button", "name", "执行", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 0 && strings.HasSuffix(arg[0], ".md") {
arg[0] = path.Join(m.Conf("note", "meta.path"), arg[0])
}
m.Cmdy(kit.Select("_tree", "_text", len(arg) > 0 && strings.HasSuffix(arg[0], ".md")), arg)
}},
"_tree": {Name: "_tree [path [true]]", Help: "文库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Option("dir_reg", ".*\\.md")
m.Option("dir_deep", kit.Select("", arg, 1))
m.Cmdy("nfs.dir", kit.Select(m.Conf("note", "meta.path"), arg, 0), m.Conf("note", "meta.head"))
}},
"_text": {Name: "_text file", Help: "文章", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if b, e := ioutil.ReadFile(arg[0]); m.Assert(e) {
data := markdown.ToHTML(b, nil, nil)
m.Echo(string(data))
}
}},
"title": {Name: "title [chapter|section|endmenu|premenu] text", Help: "标题", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "title": {Name: "title [chapter|section|endmenu|premenu] text", Help: "标题", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
title, _ := m.Optionv("title").(map[string]int) title, _ := m.Optionv("title").(map[string]int)
switch arg[0] { switch arg[0] {
@ -161,6 +134,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
m.Option(kit.MDB_TYPE, cmd) m.Option(kit.MDB_TYPE, cmd)
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])
m.Render(ice.RENDER_TEMPLATE, m.Conf(cmd, "meta.template")) m.Render(ice.RENDER_TEMPLATE, m.Conf(cmd, "meta.template"))
}}, }},
"refer": {Name: "refer name text", Help: "参考", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "refer": {Name: "refer name text", Help: "参考", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
@ -187,6 +161,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
m.Option(kit.MDB_TYPE, cmd) m.Option(kit.MDB_TYPE, cmd)
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])
m.Optionv("list", kit.Split(arg[1], "\n")) m.Optionv("list", kit.Split(arg[1], "\n"))
m.Render(ice.RENDER_TEMPLATE, m.Conf(cmd, "meta.template")) m.Render(ice.RENDER_TEMPLATE, m.Conf(cmd, "meta.template"))
}}, }},
@ -195,8 +170,8 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
m.Option(kit.MDB_TYPE, cmd) m.Option(kit.MDB_TYPE, cmd)
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])
m.Option("input", m.Cmdx("nfs.cat", arg[1]))
m.Option("input", m.Cmdx("nfs.cat", arg[1]))
switch ls := strings.Split(arg[1], "."); ls[len(ls)-1] { switch ls := strings.Split(arg[1], "."); ls[len(ls)-1] {
case "csv": case "csv":
list := []string{"<table>"} list := []string{"<table>"}
@ -220,22 +195,13 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
} }
m.Render(ice.RENDER_TEMPLATE, m.Conf(cmd, "meta.template")) m.Render(ice.RENDER_TEMPLATE, m.Conf(cmd, "meta.template"))
}}, }},
"shell": {Name: "shell name dir cmd", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "shell": {Name: "shell name text", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Option(kit.MDB_TYPE, cmd) m.Option(kit.MDB_TYPE, cmd)
m.Option(kit.MDB_NAME, arg[0]) m.Option(kit.MDB_NAME, arg[0])
m.Option("cmd_dir", arg[1]) m.Option(kit.MDB_TEXT, arg[1])
input, output := "", "" m.Option("input", strings.Join(arg[1:], " "))
switch arg = arg[2:]; arg[0] { m.Option("output", m.Cmdx(ice.CLI_SYSTEM, "sh", "-c", m.Option("input")))
case "install", "compile":
input = strings.Join(arg[1:], " ")
default:
input = strings.Join(arg, " ")
output = m.Cmdx(ice.CLI_SYSTEM, "sh", "-c", input)
}
m.Option("input", input)
m.Option("output", output)
m.Render(ice.RENDER_TEMPLATE, m.Conf(cmd, "meta.template")) m.Render(ice.RENDER_TEMPLATE, m.Conf(cmd, "meta.template"))
}}, }},
"field": {Name: "field name text", Help: "插件", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "field": {Name: "field name text", Help: "插件", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
@ -268,6 +234,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
m.Option(kit.MDB_TYPE, cmd) m.Option(kit.MDB_TYPE, cmd)
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])
m.Optionv("list", kit.Split(strings.TrimSpace(arg[1]), "\n")) m.Optionv("list", kit.Split(strings.TrimSpace(arg[1]), "\n"))
m.Render(ice.RENDER_TEMPLATE, m.Conf(cmd, "meta.template")) m.Render(ice.RENDER_TEMPLATE, m.Conf(cmd, "meta.template"))
}}, }},
@ -314,11 +281,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
Stack(m, cmd, 0, kit.Parse(nil, "", chain.show(m, arg[1])...)) Stack(m, cmd, 0, kit.Parse(nil, "", chain.show(m, arg[1])...))
m.Echo("</div>") m.Echo("</div>")
}}, }},
"chart": {Name: "chart label|chain|table name text [fg bg fs ls p m]", Help: "绘图", Meta: map[string]interface{}{}, List: kit.List( "chart": {Name: "chart label|chain|table name text [fg bg fs ls p m]", Help: "绘图", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "select", "value", "chain", "values", "block chain table",
kit.MDB_INPUT, "text", "value", "",
kit.MDB_INPUT, "button", "value", "生成",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
// 创建类型 // 创建类型
var chart Chart var chart Chart
switch arg[0] { switch arg[0] {
@ -360,37 +323,18 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
m.Render(ice.RENDER_TEMPLATE, m.Conf("chart", "meta.suffix")) m.Render(ice.RENDER_TEMPLATE, m.Conf("chart", "meta.suffix"))
}}, }},
"draw": {Name: "draw", Help: "思维导图", Meta: kit.Dict("display", "wiki/draw"), List: kit.List( "draw": {Name: "draw path auto", Help: "思维导图", Meta: kit.Dict("display", "wiki/draw"), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "path", "action", "auto",
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 0 && arg[0] == "action" { if len(arg) > 0 && arg[0] == "action" {
switch arg[1] { switch arg[1] {
case "保存": case "保存":
m.Cmd("nfs.save", path.Join(m.Conf(cmd, "meta.path"), kit.Select("hi.svg", arg[2])), arg[3:]) m.Cmd("nfs.save", path.Join(m.Conf(cmd, "meta.path"), kit.Select("hi.svg", arg[2])), arg[3:])
case "执行":
list := []string{"red", "green", "yellow", "cyan", "blue", "white", "black"}
switch kit.Select("", arg, 2) {
case "color":
m.Push("fill", list[rand.Intn(len(list))])
m.Push("fill", list[rand.Intn(len(list))])
default:
x := kit.Int(m.Option("x"))%300 + 10
m.Push("x", x)
}
} }
return return
} }
reply(m, cmd, arg...) reply(m, cmd, arg...)
}}, }},
"data": {Name: "data", Help: "数据表格", Meta: kit.Dict("display", "wiki/data"), List: kit.List( "data": {Name: "data path auto", Help: "数据表格", Meta: kit.Dict("display", "wiki/data"), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "path", "action", "auto",
kit.MDB_INPUT, "button", "name", "执行", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 0 && arg[0] == "action" { if len(arg) > 0 && arg[0] == "action" {
switch arg[1] { switch arg[1] {
case "保存": case "保存":
@ -406,11 +350,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
// 解析数据 // 解析数据
m.CSV(m.Result()) m.CSV(m.Result())
}}, }},
"word": {Name: "word", Help: "语言文字", Meta: kit.Dict("display", "wiki/word"), List: kit.List( "word": {Name: "word path auto", Help: "语言文字", Meta: kit.Dict("display", "wiki/word"), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "path", "value", "自然/编程/hi.shy",
kit.MDB_INPUT, "button", "name", "执行", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 0 && arg[0] == "action" { if len(arg) > 0 && arg[0] == "action" {
switch arg[1] { switch arg[1] {
case "story": case "story":
@ -473,11 +413,8 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
m.Optionv(ice.MSG_ALIAS, m.Confv("word", "meta.alias")) m.Optionv(ice.MSG_ALIAS, m.Confv("word", "meta.alias"))
m.Set("result").Cmdy(ice.SSH_SOURCE, path.Join(m.Conf(cmd, "meta.path"), arg[0])) m.Set("result").Cmdy(ice.SSH_SOURCE, path.Join(m.Conf(cmd, "meta.path"), arg[0]))
}}, }},
"feel": {Name: "feel", Help: "影音媒体", Meta: kit.Dict("display", "wiki/feel", "detail", []string{"标签", "删除"}), List: kit.List( "feel": {Name: "feel path auto 上传:button=@upload", Help: "影音媒体", Meta: kit.Dict(
kit.MDB_INPUT, "text", "name", "name", "display", "wiki/feel", "detail", []string{"标签", "删除"},
kit.MDB_INPUT, "button", "name", "执行",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
kit.MDB_INPUT, "button", "name", "上传", "figure", "upload",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if m.Option("_action") == "上传" { if m.Option("_action") == "上传" {
m.Cmd(ice.WEB_CACHE, "watch", m.Option("_data"), path.Join(m.Option("name"), m.Option("_name"))) m.Cmd(ice.WEB_CACHE, "watch", m.Option("_data"), path.Join(m.Option("name"), m.Option("_name")))
@ -523,11 +460,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
// 下载文件 // 下载文件
m.Echo(path.Join(m.Conf(cmd, "meta.path"), arg[0])) m.Echo(path.Join(m.Conf(cmd, "meta.path"), arg[0]))
}}, }},
"walk": {Name: "walk", Help: "走遍世界", Meta: kit.Dict("display", "wiki/walk"), List: kit.List( "walk": {Name: "walk path=@province auto", Help: "走遍世界", Meta: kit.Dict("display", "wiki/walk"), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "file", "figure", "province",
kit.MDB_INPUT, "button", "name", "执行",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 0 && arg[0] == "action" { if len(arg) > 0 && arg[0] == "action" {
switch arg[1] { switch arg[1] {
case "保存": case "保存":

View File

@ -28,8 +28,7 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
Caches: map[string]*ice.Cache{}, Caches: map[string]*ice.Cache{},
Configs: map[string]*ice.Config{ Configs: map[string]*ice.Config{
"git": {Name: "git", Help: "代码库", Value: kit.Data( "git": {Name: "git", Help: "代码库", Value: kit.Data(
"source", "https://github.com/git/git.git", "source", "https://github.com/git/git.git", "config", kit.Dict(
"config", kit.Dict(
"alias", kit.Dict("s", "status", "b", "branch"), "alias", kit.Dict("s", "status", "b", "branch"),
"color", kit.Dict("ui", "true"), "color", kit.Dict("ui", "true"),
"push", kit.Dict("default", "simple"), "push", kit.Dict("default", "simple"),
@ -59,6 +58,8 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
}) })
}) })
}}, }},
ice.CODE_PROJECT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}},
"init": {Name: "init", Help: "初始化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "init": {Name: "init", Help: "初始化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
// 系统项目 // 系统项目
@ -75,12 +76,12 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
add(m, value["name"], value["path"]) add(m, value["name"], value["path"])
}) })
}}, }},
"auto": {Name: "auto", Help: "自动化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}},
"load": {Name: "load", Help: "序列化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}},
"repos": {Name: "repos [name [path [remote [branch]]]]", Help: "仓库", List: kit.List( "repos": {Name: "repos [name=auto [path [remote [branch]]]] auto", Help: "代码仓库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "name", "action", "auto",
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 1 { if len(arg) > 1 {
if _, e := os.Stat(path.Join(arg[1], ".git")); e != nil && os.IsNotExist(e) { if _, e := os.Stat(path.Join(arg[1], ".git")); e != nil && os.IsNotExist(e) {
// 下载仓库 // 下载仓库
@ -104,11 +105,7 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
}) })
m.Sort("name") m.Sort("name")
}}, }},
"total": {Name: "total", Help: "统计", List: kit.List( "total": {Name: "total name auto", Help: "提交统计", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "name", "action", "auto",
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 0 { if len(arg) > 0 {
// 提交详情 // 提交详情
m.Richs("repos", nil, arg[0], func(key string, value map[string]interface{}) { m.Richs("repos", nil, arg[0], func(key string, value map[string]interface{}) {
@ -150,15 +147,11 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
m.Push("rest", rest) m.Push("rest", rest)
m.Sort("adds", "int_r") m.Sort("adds", "int_r")
}}, }},
"status": {Name: "status repos", Help: "状态", Meta: kit.Dict( "status": {Name: "status name auto", Help: "文件状态", Meta: kit.Dict(
"detail", []interface{}{"add", "reset", "remove", kit.Dict("name", "commit", "args", kit.List( "detail", []interface{}{"add", "reset", "remove", kit.Dict("name", "commit", "args", kit.List(
kit.MDB_INPUT, "select", "name", "type", "values", []string{"add", "opt"}, kit.MDB_INPUT, "select", "name", "type", "values", []string{"add", "opt"},
kit.MDB_INPUT, "text", "name", "name", "value", "some", kit.MDB_INPUT, "text", "name", "name", "value", "some",
))}, ))},
), List: kit.List(
kit.MDB_INPUT, "text", "name", "name", "action", "auto",
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
prefix := []string{ice.CLI_SYSTEM, "git"} prefix := []string{ice.CLI_SYSTEM, "git"}
@ -272,11 +265,8 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
} }
}}, }},
"trend": {Name: "check name [path [repos]]", Help: "检查", Meta: kit.Dict("display", "/plugin/story/trend"), List: kit.List( "trend": {Name: "trend name=auto begin_time=@date auto", Help: "趋势图", Meta: kit.Dict(
kit.MDB_INPUT, "text", "name", "repos", "action", "auto", "display", "/plugin/story/trend",
kit.MDB_INPUT, "text", "name", "begin_time", "figure", "date",
kit.MDB_INPUT, "button", "name", "执行", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 0 { if len(arg) == 0 {
m.Option("_display", "table") m.Option("_display", "table")

View File

@ -157,7 +157,4 @@ var Index = &ice.Context{Name: "input", Help: "输入法",
}, },
} }
// ice add person 码神 dcpy
// 码神
func init() { code.Index.Register(Index, nil) } func init() { code.Index.Register(Index, nil) }

54
misc/md/md.go Normal file
View File

@ -0,0 +1,54 @@
package md
import (
"github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/core/wiki"
"github.com/shylinux/toolkits"
"github.com/gomarkdown/markdown"
"io/ioutil"
"math/rand"
)
var Index = &ice.Context{Name: "md", Help: "md",
Caches: map[string]*ice.Cache{},
Configs: map[string]*ice.Config{
"note": {Name: "note", Help: "笔记", Value: kit.Data(
"path", "", "head", "time size line path",
)},
"md": {Name: "md", Help: "md", Value: kit.Data(kit.MDB_SHORT, "name")},
},
Commands: map[string]*ice.Command{
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
"md": {Name: "md", Help: "md", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Echo("hello world")
}},
"note": {Name: "note file", Help: "文档", Meta: kit.Dict("display", "inner"), List: kit.List(
kit.MDB_INPUT, "text", "name", "path", "value", "README.md", "action", "auto",
kit.MDB_INPUT, "button", "name", "执行", "action", "auto",
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) > 0 && strings.HasSuffix(arg[0], ".md") {
arg[0] = path.Join(m.Conf("note", "meta.path"), arg[0])
}
m.Cmdy(kit.Select("_tree", "_text", len(arg) > 0 && strings.HasSuffix(arg[0], ".md")), arg)
}},
"_tree": {Name: "_tree [path [true]]", Help: "文库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Option("dir_reg", ".*\\.md")
m.Option("dir_deep", kit.Select("", arg, 1))
m.Cmdy("nfs.dir", kit.Select(m.Conf("note", "meta.path"), arg, 0), m.Conf("note", "meta.head"))
}},
"_text": {Name: "_text file", Help: "文章", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if b, e := ioutil.ReadFile(arg[0]); m.Assert(e) {
data := markdown.ToHTML(b, nil, nil)
m.Echo(string(data))
}
}},
},
}
func init() { wiki.Index.Register(Index, nil) }

9
misc/md/md.js Normal file
View File

@ -0,0 +1,9 @@
Volcanos("onimport", {help: "导入数据", list: [],
"init": function(can, msg, cb, output, action, option) {},
})
Volcanos("onaction", {help: "控件菜单", list: []})
Volcanos("onchoice", {help: "控件交互", list: ["刷新"]
"刷新": function(event, can, value, cmd, target) {},
})
Volcanos("ondetail", {help: "控件详情", list: []})
Volcanos("onexport", {help: "导出数据", list: []})

1
misc/md/md.shy Normal file
View File

@ -0,0 +1 @@
title "md"

96
misc/railway/railway.go Normal file
View File

@ -0,0 +1,96 @@
package railway
import (
"github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/core/wiki"
"github.com/shylinux/toolkits"
)
var Index = &ice.Context{Name: "railway", Help: "railway",
Caches: map[string]*ice.Cache{},
Configs: map[string]*ice.Config{
"railway": {Name: "railway", Help: "12306", Value: kit.Data("site", "https://kyfw.12306.cn")},
},
Commands: map[string]*ice.Command{
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Load()
m.Cmd(ice.WEB_SPIDE, "add", "12306", m.Conf("railway", "meta.site"))
}},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Save("railway")
}},
"railway": &ice.Command{Name: "railway", Help: "12306", List: kit.List(
kit.MDB_INPUT, "text", "name", "date", "figure", "date",
kit.MDB_INPUT, "text", "name", "from", "value", "北京", "figure", "city",
kit.MDB_INPUT, "text", "name", "to", "value", "曲阜", "figure", "city",
kit.MDB_INPUT, "button", "name", "查询",
), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
if !m.Confs("railway", "meta.place") {
list := strings.Split(strings.TrimPrefix(m.Cmdx(ice.WEB_SPIDE, "12306", "raw", "GET", "/otn/resources/js/framework/station_name.js?station_version=1.9090"), "var statuion_names ='"), "|")
for i := 0; i < len(list)-5; i += 5 {
m.Conf("railway", kit.Keys("meta.place", list[i+1]), list[i+2])
}
}
date := strings.Split(m.Time("24h"), " ")[0]
if len(arg) > 0 {
date, arg = arg[0], arg[1:]
}
date = strings.Split(date, " ")[0]
from := "北京"
if len(arg) > 0 {
from, arg = arg[0], arg[1:]
}
from_code := m.Conf("railway", kit.Keys("meta.place", from))
to := "曲阜"
if len(arg) > 0 {
to, arg = arg[0], arg[1:]
}
to_code := m.Conf("railway", kit.Keys("meta.place", to))
m.Echo("%s->%s %s\n", from, to, date)
if len(arg) > 0 {
m.Cmdy(ice.WEB_SPIDE, "12306", "raw", "GET", fmt.Sprintf("/otn/czxx/queryByTrainNo?train_no=%s&from_station_telecode=%s&to_station_telecode=%s&depart_date=%s",
arg[0], from_code, to_code, date))
return
}
m.Cmd(ice.WEB_SPIDE, "12306", "GET", fmt.Sprintf("/otn/leftTicket/init?linktypeid=dc&fs=%s,%s&ts=%s,%s&date=%s&flag=N,N,Y",
from, from_code, to, to_code, date))
m.Cmd(ice.WEB_SPIDE, "12306", "GET", fmt.Sprintf("/otn/leftTicket/queryZ?leftTicketDTO.train_date=%s&leftTicketDTO.from_station=%s&leftTicketDTO.to_station=%s&purpose_codes=ADULT",
date, from_code, to_code)).Table(func(index int, value map[string]string, head []string) {
kit.Fetch(kit.Value(kit.UnMarshal(value["data"]), "result"), func(index int, value string) {
fields := strings.Split(value, "|")
m.Push("车次", fields[3])
m.Push("出发", fields[8])
m.Push("到站", fields[9])
m.Push("时长", fields[10])
m.Push("二等座", fields[30])
m.Push("一等座", fields[31])
})
})
}},
"passcode": &ice.Command{Name: "passcode", Help: "passcode", Meta: kit.Dict("active", "mall/input"), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
prefix := []string{ice.WEB_SPIDE, "12306"}
if len(arg) == 0 {
m.Cmd(prefix, "raw", "/passport/web/auth/uamtk-static", "form", "appid", "otn")
m.Cmd(prefix, "raw", "GET", "/otn/HttpZF/GetJS")
m.Cmd(prefix, "raw", "/otn/login/conf")
m.Cmdy(prefix, "GET", fmt.Sprintf("/passport/captcha/captcha-image64?login_site=E&module=login&rand=sjrand"))
return
}
switch arg[0] {
case "check":
m.Cmdy(prefix, "GET", fmt.Sprintf("/passport/captcha/captcha-check?login_site=E&rand=sjrand&answer=%s", arg[1]))
case "login":
m.Cmdy(prefix, "raw", "/passport/web/login", "form", "username", arg[1], "password", arg[2], "answer", arg[3], "appid", "otn")
}
}},
},
}
func init() { wiki.Index.Register(Index, nil) }

9
misc/railway/railway.js Normal file
View File

@ -0,0 +1,9 @@
Volcanos("onimport", {help: "导入数据", list: [],
"init": function(can, msg, cb, output, action, option) {},
})
Volcanos("onaction", {help: "控件菜单", list: []})
Volcanos("onchoice", {help: "控件交互", list: ["刷新"]
"刷新": function(event, can, value, cmd, target) {},
})
Volcanos("ondetail", {help: "控件详情", list: []})
Volcanos("onexport", {help: "导出数据", list: []})

1
misc/railway/railway.shy Normal file
View File

@ -0,0 +1 @@
title "railway"

View File

@ -42,6 +42,14 @@ var Index = &ice.Context{Name: "tmux", Help: "工作台",
)}, )},
}, },
Commands: map[string]*ice.Command{ Commands: map[string]*ice.Command{
ice.CODE_INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}},
ice.CODE_PREPARE: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmd("nfs.link", path.Join(os.Getenv("HOME"), ".tmux.conf"), "etc/conf/tmux.conf")
}},
ice.CODE_PROJECT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}},
"init": {Name: "init", Help: "初始化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "init": {Name: "init", Help: "初始化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Watch(ice.DREAM_START, m.Prefix("auto")) m.Watch(ice.DREAM_START, m.Prefix("auto"))
@ -111,24 +119,17 @@ var Index = &ice.Context{Name: "tmux", Help: "工作台",
m.Cmdy(prefix, "send-keys", "-t", arg[0], v, "Enter") m.Cmdy(prefix, "send-keys", "-t", arg[0], v, "Enter")
} }
}}, }},
"load": {Name: "load", Help: "序列化", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}},
"text": {Name: "text", Help: "文本", List: kit.List( "text": {Name: "text name 保存:button text:textarea", Help: "文本", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "name",
kit.MDB_INPUT, "button", "value", "保存",
kit.MDB_INPUT, "textarea", "name", "text",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
prefix := kit.Simple(m.Confv("prefix", "meta.cmd")) prefix := kit.Simple(m.Confv("prefix", "meta.cmd"))
if len(arg) > 1 && arg[1] != "" { if len(arg) > 1 && arg[1] != "" {
m.Cmd(prefix, "set-buffer", arg[1]) m.Cmd(prefix, "set-buffer", arg[1])
} }
m.Cmdy(prefix, "show-buffer").Set(ice.MSG_APPEND) m.Cmdy(prefix, "show-buffer").Set(ice.MSG_APPEND)
}}, }},
"buffer": {Name: "buffer", Help: "缓存", List: kit.List( "buffer": {Name: "buffer [buffer=auto [value]] auto", Help: "缓存", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
kit.MDB_INPUT, "text", "name", "buffer", "action", "auto",
kit.MDB_INPUT, "text", "name", "value",
kit.MDB_INPUT, "button", "value", "查看", "action", "auto",
kit.MDB_INPUT, "button", "value", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
prefix := kit.Simple(m.Confv("prefix", "meta.cmd")) prefix := kit.Simple(m.Confv("prefix", "meta.cmd"))
if len(arg) > 1 { if len(arg) > 1 {
// 设置缓存 // 设置缓存
@ -153,12 +154,8 @@ var Index = &ice.Context{Name: "tmux", Help: "工作台",
} }
} }
}}, }},
"session": {Name: "session [session [window [pane [cmd]]]]", Help: "会话", Meta: kit.Dict("detail", []string{"选择", "编辑", "删除", "下载"}), List: kit.List( "session": {Name: "session [session=auto [window=auto [pane=auto [cmd]]]] auto", Help: "会话", Meta: kit.Dict(
kit.MDB_INPUT, "text", "name", "session", "action", "auto", "detail", []string{"选择", "编辑", "删除", "下载"},
kit.MDB_INPUT, "text", "name", "window", "action", "auto",
kit.MDB_INPUT, "text", "name", "pane", "action", "auto",
kit.MDB_INPUT, "button", "value", "查看", "action", "auto",
kit.MDB_INPUT, "button", "value", "返回", "cb", "Last",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
prefix := kit.Simple(m.Confv("prefix", "meta.cmd")) prefix := kit.Simple(m.Confv("prefix", "meta.cmd"))

10
type.go
View File

@ -869,11 +869,15 @@ func (m *Message) TryCatch(msg *Message, safe bool, hand ...func(msg *Message))
case io.EOF: case io.EOF:
case nil: case nil:
default: default:
m.Log(LOG_WARN, "catch: %s", e) _, file, line, _ := runtime.Caller(3)
if list := strings.Split(file, "/"); len(list) > 2 {
file = strings.Join(list[len(list)-2:], "/")
}
m.Log(LOG_WARN, "catch: %s %s:%d", e, file, line)
m.Log(LOG_INFO, "chain: %s", msg.Format("chain")) m.Log(LOG_INFO, "chain: %s", msg.Format("chain"))
m.Log(LOG_WARN, "catch: %s", e) m.Log(LOG_WARN, "catch: %s %s:%d", e, file, line)
m.Log(LOG_INFO, "stack: %s", msg.Format("stack")) m.Log(LOG_INFO, "stack: %s", msg.Format("stack"))
if m.Log(LOG_WARN, "catch: %s", e); len(hand) > 1 { if m.Log(LOG_WARN, "catch: %s %s:%d", e, file, line); len(hand) > 1 {
// 捕获异常 // 捕获异常
m.TryCatch(msg, safe, hand[1:]...) m.TryCatch(msg, safe, hand[1:]...)
} else if !safe { } else if !safe {