1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 01:24:05 +08:00
This commit is contained in:
harveyshao 2022-10-23 00:18:01 +08:00
parent 1348b8a1f5
commit f93de948d6
3 changed files with 31 additions and 14 deletions

View File

@ -185,7 +185,7 @@ const RUNTIME = "runtime"
func init() {
Index.MergeCommands(ice.Commands{
RUNTIME: {Name: "runtime info=ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,bootinfo,api,cli,cmd,env auto Terminal Chrome", Help: "运行环境", Actions: ice.Actions{
RUNTIME: {Name: "runtime info=ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,bootinfo,api,cli,cmd,env auto", Help: "运行环境", Actions: ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
cs := m.Target().Configs
if _, ok := cs[RUNTIME]; !ok {

View File

@ -177,8 +177,8 @@ const (
)
const HASH = "hash"
func HashAction(args ...Any) ice.Actions {
return ice.Actions{ice.CTX_INIT: AutoConfig(args...), ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { HashSelectClose(m) }},
func HashAction(arg ...Any) ice.Actions {
return ice.Actions{ice.CTX_INIT: AutoConfig(arg...), ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { HashSelectClose(m) }},
INPUTS: {Hand: func(m *ice.Message, arg ...string) { HashInputs(m, arg) }},
CREATE: {Name: "create", Help: "创建", Hand: func(m *ice.Message, arg ...string) { HashCreate(m, arg) }},
REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) { HashRemove(m, arg) }},

View File

@ -3,9 +3,12 @@ package wiki
import (
"bytes"
"encoding/csv"
"path"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/lex"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
kit "shylinux.com/x/toolkits"
)
@ -13,22 +16,36 @@ import (
const DATA = "data"
func init() {
Index.Merge(&ice.Context{Configs: ice.Configs{
DATA: {Name: DATA, Help: "数据表格", Value: kit.Data(nfs.PATH, ice.USR_LOCAL_EXPORT, lex.REGEXP, ".*\\.csv")},
}, Commands: ice.Commands{
DATA: {Name: "data path auto", Help: "数据表格", Meta: kit.Dict(ice.DisplayLocal("")), Actions: ice.Actions{
nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
_wiki_save(m, m.CommandKey(), arg[0], arg[1])
Index.MergeCommands(ice.Commands{
DATA: {Name: "data path type@key fields auto create push save draw", Help: "数据表格", Actions: ice.MergeActions(ice.Actions{
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
switch arg[0] {
case mdb.TYPE:
m.Push(arg[0], "折线图", "比例图")
}
}},
}, Hand: func(m *ice.Message, arg ...string) {
mdb.CREATE: {Name: "create path fields value", Hand: func(m *ice.Message, arg ...string) {
m.Cmd("", nfs.SAVE, m.Option(nfs.PATH), kit.Join(kit.Split(m.Option("fields")), ice.FS)+ice.NL+kit.Join(kit.Split(m.Option("value")))+ice.NL)
}},
nfs.PUSH: {Name: "push path record", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
m.Cmd(nfs.PUSH, path.Join(m.Config(nfs.PATH), arg[0]), kit.Join(arg[1:], ice.FS)+ice.NL)
}},
}, FileAction(nfs.PATH, ice.USR_LOCAL_EXPORT, lex.REGEXP, ".*\\.csv")), Hand: func(m *ice.Message, arg ...string) {
if !_wiki_list(m, m.CommandKey(), kit.Select(nfs.PWD, arg, 0)) {
CSV(m, m.Cmd(nfs.CAT, arg[0]).Result())
m.StatusTimeCount()
CSV(m, m.Cmd(nfs.CAT, arg[0]).Result()).StatusTimeCount()
ctx.DisplayLocal(m, "")
}
}},
}})
})
}
func FileAction(arg ...ice.Any) ice.Actions {
return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(arg...),
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(nfs.TRASH, path.Join(m.Config(nfs.PATH), m.Option(nfs.PATH))) }},
nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
m.Cmd(nfs.SAVE, arg[0], arg[1], kit.Dict(nfs.DIR_ROOT, m.Config(nfs.PATH)))
}},
}
}
func CSV(m *ice.Message, text string, head ...string) *ice.Message {
bio := bytes.NewBufferString(text)
r := csv.NewReader(bio)