mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
opt some
This commit is contained in:
parent
edf04423eb
commit
629744f18c
@ -34,9 +34,6 @@ func _config_save(m *ice.Message, name string, arg ...string) {
|
||||
for _, k := range arg {
|
||||
if v := msg.Confv(k); v != "" {
|
||||
data[k] = v
|
||||
if k == "web.code.trpc.oauth" {
|
||||
m.Debug("wha5 %v %v", k, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,9 +43,6 @@ func _config_save(m *ice.Message, name string, arg ...string) {
|
||||
m.Log_EXPORT(CONFIG, name, nfs.FILE, p, nfs.SIZE, n)
|
||||
}
|
||||
}
|
||||
if name == "var/conf/web.code.trpc.json" {
|
||||
m.Debug("wha5 %v %v %v", name, p, data)
|
||||
}
|
||||
m.Echo(p)
|
||||
}
|
||||
}
|
||||
|
@ -143,6 +143,7 @@ const (
|
||||
CSV = ice.CSV
|
||||
JSON = ice.JSON
|
||||
|
||||
PY = "py"
|
||||
TXT = "txt"
|
||||
IML = "iml"
|
||||
XML = "xml"
|
||||
|
@ -148,7 +148,7 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon
|
||||
if r.ParseForm(); len(r.PostForm) > 0 {
|
||||
for k, v := range r.PostForm {
|
||||
if len(v) > 1 {
|
||||
msg.Logs("form", k, len(v), v)
|
||||
msg.Logs("form", k, len(v), kit.Format(v))
|
||||
} else {
|
||||
msg.Logs("form", k, v)
|
||||
}
|
||||
@ -196,13 +196,10 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon
|
||||
// 输出响应
|
||||
switch args := msg.Optionv(ice.MSG_ARGS).(type) {
|
||||
case []interface{}:
|
||||
msg.Debug("what %v", args)
|
||||
Render(msg, msg.Option(ice.MSG_OUTPUT), args...)
|
||||
case []string:
|
||||
msg.Debug("what %v", args)
|
||||
Render(msg, msg.Option(ice.MSG_OUTPUT), args)
|
||||
default:
|
||||
msg.Debug("what %v", args)
|
||||
Render(msg, msg.Option(ice.MSG_OUTPUT), kit.List())
|
||||
}
|
||||
}
|
||||
|
@ -128,11 +128,11 @@ func init() {
|
||||
}
|
||||
}},
|
||||
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if msg := m.Cmd(ctx.COMMAND, arg[0]); msg.Length() > 0 {
|
||||
m.RenderCmd(arg[0])
|
||||
if _cmd_file(m, arg...) {
|
||||
return
|
||||
}
|
||||
if _cmd_file(m, arg...) {
|
||||
if msg := m.Cmd(ctx.COMMAND, arg[0]); msg.Length() > 0 {
|
||||
m.RenderCmd(arg[0])
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -222,6 +222,10 @@ func init() {
|
||||
})
|
||||
}},
|
||||
"show": {Hand: func(m *ice.Message, arg ...string) {
|
||||
if kit.Ext(arg[0]) == nfs.ZML {
|
||||
m.RenderCmd("can.parse", m.Cmdx(nfs.CAT, path.Join(SRC_WEBSITE, arg[0])))
|
||||
return
|
||||
}
|
||||
if text := m.Cmd(m.PrefixKey(), ice.PS+arg[0]).Append(mdb.TEXT); text != "" {
|
||||
if res, ok := _website_parse(m, text, arg[1:]...); ok {
|
||||
m.Echo(_website_template2, kit.Format(res))
|
||||
|
@ -141,17 +141,25 @@ func init() {
|
||||
}
|
||||
_binpack_ctx(m, f)
|
||||
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.GO_MOD))
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.GO_SUM))
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.MAKEFILE))
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.ETC_MISS_SH))
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.ETC_INIT_SHY))
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.ETC_EXIT_SHY))
|
||||
fmt.Fprintln(f)
|
||||
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.GO_MOD))
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.GO_SUM))
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.MAKEFILE))
|
||||
fmt.Fprintln(f, _binpack_file(m, ice.README_MD))
|
||||
fmt.Fprintln(f)
|
||||
|
||||
m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH, ice.OptionFields(nfs.PATH)).Tables(func(value map[string]string) {
|
||||
_binpack_dir(m, f, value[nfs.PATH])
|
||||
if s, e := os.Stat(value[nfs.PATH]); e == nil {
|
||||
if s.IsDir() {
|
||||
_binpack_dir(m, f, value[nfs.PATH])
|
||||
} else {
|
||||
fmt.Fprintln(f, _binpack_file(m, value[nfs.PATH]))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}},
|
||||
|
@ -10,15 +10,25 @@ import (
|
||||
)
|
||||
|
||||
const PY = "py"
|
||||
const (
|
||||
PYTHON2 = "python2"
|
||||
)
|
||||
|
||||
func init() {
|
||||
const PYTHON2 = "python2"
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
PY: {Name: "py", Help: "脚本", Action: map[string]*ice.Action{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(mdb.ENGINE, mdb.CREATE, PY, m.PrefixKey())
|
||||
m.Cmd(mdb.RENDER, mdb.CREATE, PY, m.PrefixKey())
|
||||
}},
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if kit.FileExists(kit.Path(arg[2], arg[1])) {
|
||||
m.Cmdy(cli.SYSTEM, PYTHON2, kit.Path(arg[2], arg[1]))
|
||||
} else if b, ok := ice.Info.Pack[path.Join(arg[2], arg[1])]; ok && len(b) > 0 {
|
||||
m.Cmdy(cli.SYSTEM, PYTHON2, "-c", string(b))
|
||||
}
|
||||
if cli.IsSuccess(m) {
|
||||
m.SetAppend()
|
||||
}
|
||||
m.Echo(ice.NL)
|
||||
}},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if kit.FileExists(kit.Path(arg[2], arg[1])) {
|
||||
@ -28,8 +38,6 @@ func init() {
|
||||
}
|
||||
m.Echo(ice.NL)
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ func init() {
|
||||
}
|
||||
LoadPlug(m, SH)
|
||||
}},
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(cli.SYSTEM, SH, "-c", kit.Join(_sh_main_script(m, arg...), ice.NL)).SetAppend()
|
||||
}},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(cli.SYSTEM, SH, "-c", kit.Join(_sh_main_script(m, arg...), ice.NL)).SetAppend()
|
||||
}},
|
||||
|
@ -24,13 +24,85 @@ func init() {
|
||||
AUTOGEN: {Name: "create main=src/main.go zone name=hi help type=Zone,Hash,Lists,Data,Code list key", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(AUTOGEN, mdb.CREATE, arg)
|
||||
}},
|
||||
web.DREAM: {Name: "dream name=hi repos", Help: "空间", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(web.DREAM, cli.START, arg)
|
||||
COMPILE: {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
||||
if msg := m.Cmd(COMPILE, ice.SRC_MAIN_GO, ice.BIN_ICE_BIN); !cli.IsSuccess(msg) {
|
||||
_inner_make(m, msg)
|
||||
} else {
|
||||
m.Cmd(UPGRADE, cli.RESTART)
|
||||
}
|
||||
}},
|
||||
"script": {Name: "script file=hi/hi.js text=", Help: "脚本", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(mdb.TEXT, strings.TrimSpace(m.Option(mdb.TEXT)))
|
||||
m.Cmdy(TEMPLATE, nfs.DEFS)
|
||||
}},
|
||||
web.DREAM: {Name: "dream name=hi repos", Help: "空间", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(web.DREAM, cli.START, arg)
|
||||
}},
|
||||
"website": {Name: "script file=hi.zml@key text@key", Help: "网页", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.FILE, path.Join("website", m.Option(nfs.FILE)))
|
||||
m.Option(mdb.TEXT, strings.TrimSpace(m.Option(mdb.TEXT)))
|
||||
m.Cmdy(TEMPLATE, nfs.DEFS)
|
||||
}},
|
||||
PUBLISH: {Name: "publish", Help: "发布", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(PUBLISH, ice.CONTEXTS)
|
||||
}},
|
||||
|
||||
mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[0] == mdb.FOREACH && arg[1] == "" {
|
||||
m.PushSearch(mdb.TYPE, "go", mdb.NAME, "src/main.go", mdb.TEXT, m.MergeCmd(""))
|
||||
}
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
switch m.Option(ctx.ACTION) {
|
||||
case web.DREAM:
|
||||
m.Cmdy(web.DREAM, mdb.INPUTS, arg)
|
||||
case "script":
|
||||
switch arg[0] {
|
||||
case nfs.FILE:
|
||||
file, ext := m.Option(nfs.FILE), kit.Ext(m.Option(nfs.FILE))
|
||||
for _, t := range []string{nfs.SH, nfs.SHY, nfs.PY, nfs.JS} {
|
||||
m.Push(nfs.FILE, strings.ReplaceAll(file, ice.PT+ext, ice.PT+t))
|
||||
}
|
||||
case mdb.TEXT:
|
||||
m.Push(mdb.TEXT, `echo "hello world"`)
|
||||
m.Push(mdb.TEXT, `chapter "hi"`)
|
||||
m.Push(mdb.TEXT, `print "hello world"`)
|
||||
m.Push(mdb.TEXT, `Volcanos("onimport", {help: "导入数据", list:[], _init: function(can, msg, cb, target) {
|
||||
msg.Echo("hello world")
|
||||
can.onappend.table(can, msg)
|
||||
can.onappend.board(can, msg)
|
||||
}})`)
|
||||
}
|
||||
case "website":
|
||||
switch arg[0] {
|
||||
case nfs.FILE:
|
||||
m.Push(nfs.FILE, "hi.zml")
|
||||
m.Push(nfs.FILE, "hi.iml")
|
||||
case mdb.TEXT:
|
||||
m.Push(mdb.TEXT, `
|
||||
hi
|
||||
he
|
||||
cli.runtime
|
||||
cli.system
|
||||
hi/hi.sh
|
||||
hi/hi.go
|
||||
hi/hi.js
|
||||
`)
|
||||
m.Push(mdb.TEXT, `
|
||||
left
|
||||
username
|
||||
系统
|
||||
命令 index cli.system
|
||||
共享 index cli.qrcode
|
||||
代码
|
||||
趋势 index web.code.git.trend args icebergs action auto
|
||||
状态 index web.code.git.status args icebergs
|
||||
main
|
||||
`)
|
||||
}
|
||||
default:
|
||||
}
|
||||
}},
|
||||
"complete": {Name: "complete", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
switch m.Option("key") {
|
||||
case "ice", "*ice":
|
||||
@ -57,30 +129,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
}},
|
||||
"website": {Name: "script file=hi.iml text=", Help: "网页", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.FILE, path.Join("website", m.Option(nfs.FILE)))
|
||||
m.Option(mdb.TEXT, strings.TrimSpace(m.Option(mdb.TEXT)))
|
||||
m.Cmdy(TEMPLATE, nfs.DEFS)
|
||||
}},
|
||||
mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[0] == mdb.FOREACH && arg[1] == "" {
|
||||
m.PushSearch(mdb.TYPE, "go", mdb.NAME, "src/main.go", mdb.TEXT, m.MergeCmd(""))
|
||||
}
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
switch m.Option(ctx.ACTION) {
|
||||
case web.DREAM:
|
||||
m.Cmdy(web.DREAM, mdb.INPUTS, arg)
|
||||
}
|
||||
}},
|
||||
|
||||
COMPILE: {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
||||
if msg := m.Cmd(COMPILE, ice.SRC_MAIN_GO, ice.BIN_ICE_BIN); !cli.IsSuccess(msg) {
|
||||
_inner_make(m, msg)
|
||||
} else {
|
||||
m.Cmd(UPGRADE, cli.RESTART)
|
||||
}
|
||||
}},
|
||||
"unpack": {Name: "unpack", Help: "导出文件", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(BINPACK, mdb.EXPORT)
|
||||
}},
|
||||
|
@ -10,7 +10,7 @@ const TODO = "todo"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
TODO: {Name: "todo hash auto create", Help: "待办", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
TODO: {Name: "todo hash auto create export import", Help: "待办", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.INPUTS, m.PrefixKey(), "", mdb.HASH, arg)
|
||||
m.Cmdy(TASK, mdb.INPUTS, arg)
|
||||
@ -23,6 +23,7 @@ func init() {
|
||||
}, mdb.HashAction(mdb.FIELD, "time,hash,zone,name,text")), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Display("/plugin/table.js", "style", "card")
|
||||
mdb.HashSelect(m, arg...).PushAction(cli.START, mdb.REMOVE)
|
||||
m.PushPodCmd(cmd, arg...)
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
3
init.go
3
init.go
@ -74,7 +74,6 @@ var Index = &Context{Name: "ice", Help: "冰山模块", Configs: map[string]*Con
|
||||
EXIT: {Name: "exit", Help: "结束", Hand: func(m *Message, c *Context, cmd string, arg ...string) {
|
||||
m.root.Option(EXIT, kit.Select("0", arg, 0))
|
||||
defer c.Close(m.root.Spawn(), arg...)
|
||||
defer m.Sleep("1s")
|
||||
|
||||
m.Cmd("source", ETC_EXIT_SHY)
|
||||
m.root.Cmd(CTX_EXIT)
|
||||
@ -138,7 +137,7 @@ func Run(arg ...string) string {
|
||||
}
|
||||
|
||||
Pulse.Cmd(INIT)
|
||||
defer Pulse.Cmd(EXIT)
|
||||
// defer Pulse.Cmd(EXIT)
|
||||
if Pulse.Cmdy(arg); strings.TrimSpace(Pulse.Result()) == "" {
|
||||
Pulse.Table()
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ func init() {
|
||||
|
||||
m.Option(cli.CMD_DIR, _repos_path(arg[0]))
|
||||
m.Echo(m.Cmdx(cli.SYSTEM, GIT, DIFF))
|
||||
m.Action(COMMIT, BRANCH, TAGS)
|
||||
m.Action(COMMIT, TAGS, BRANCH)
|
||||
|
||||
files, adds, dels := _status_stat(m, 0, 0, 0)
|
||||
m.Status("files", files, "adds", adds, "dels", dels)
|
||||
|
@ -194,7 +194,7 @@ func (m *Message) PushPodCmd(cmd string, arg ...string) {
|
||||
})
|
||||
}
|
||||
|
||||
m.Cmd(SPACE).Table(func(index int, value map[string]string, head []string) {
|
||||
m.Cmd(SPACE, OptionFields("type,name")).Table(func(index int, value map[string]string, head []string) {
|
||||
switch value[TYPE] {
|
||||
case "server", "worker":
|
||||
if value[NAME] == Info.HostName {
|
||||
|
Loading…
x
Reference in New Issue
Block a user