1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 09:34:05 +08:00

opt vimer.js

This commit is contained in:
harveyshao 2022-07-13 17:47:07 +08:00
parent 05c4c401e6
commit 475250ec71
6 changed files with 104 additions and 72 deletions

View File

@ -169,21 +169,22 @@ func init() {
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
switch arg[0] { switch arg[0] {
case cli.MAIN: case cli.MAIN:
m.Cmdy(nfs.DIR, ice.SRC, nfs.DIR_CLI_FIELDS, kit.Dict(nfs.DIR_REG, `.*\.go`)).RenameAppend(nfs.PATH, arg[0]) m.Option(nfs.DIR_ROOT, ice.SRC)
m.Cmdy(nfs.DIR, nfs.PWD, nfs.DIR_CLI_FIELDS, kit.Dict(nfs.DIR_REG, `.*\.go`)).RenameAppend(nfs.PATH, arg[0])
} }
}}, }},
mdb.CREATE: {Name: "create main=src/main.go@key zone name=hi help type=Hash,Zone,Lists,Data,Code key", Help: "模块", Hand: func(m *ice.Message, arg ...string) { mdb.CREATE: {Name: "create name=hi help type=Hash,Zone,Lists,Data,Code main=main.go@key zone key", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
_defs(m, mdb.ZONE, m.Option(mdb.NAME), mdb.HELP, m.Option(mdb.NAME)) _defs(m, mdb.ZONE, m.Option(mdb.NAME), mdb.HELP, m.Option(mdb.NAME))
_defs(m, mdb.KEY, kit.Keys("web.code", m.Option(mdb.ZONE), m.Option(mdb.NAME))) _defs(m, mdb.KEY, kit.Keys("web.code", m.Option(mdb.ZONE), m.Option(mdb.NAME)))
m.Option(mdb.TEXT, kit.Format("`name:\"%s\" help:\"%s\"`", _defs_list(m), m.Option(mdb.HELP))) m.Option(mdb.TEXT, kit.Format("`name:\"%s\" help:\"%s\"`", _defs_list(m), m.Option(mdb.HELP)))
if p := path.Join(ice.SRC, m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO)); !kit.FileExists(p) { if p := path.Join(ice.SRC, m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO)); !kit.FileExists(p) {
_autogen_module(m, p) _autogen_module(m, p)
_autogen_import(m, m.Option(cli.MAIN), m.Option(mdb.ZONE), _autogen_mod(m, ice.GO_MOD)) _autogen_import(m, path.Join(ice.SRC, m.Option(cli.MAIN)), m.Option(mdb.ZONE), _autogen_mod(m, ice.GO_MOD))
} }
if p := path.Join(ice.SRC, m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), SHY)); !kit.FileExists(p) { if p := path.Join(ice.SRC, m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), SHY)); !kit.FileExists(p) {
_autogen_script(m, p) _autogen_script(m, p)
_autogen_source(m, m.Option(cli.MAIN), p) _autogen_source(m, path.Join(ice.SRC, m.Option(cli.MAIN)), p)
} }
m.Option(nfs.FILE, path.Join(m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO))) m.Option(nfs.FILE, path.Join(m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO)))
_autogen_version(m.Spawn()) _autogen_version(m.Spawn())

View File

@ -73,15 +73,15 @@ func init() {
_autogen_version(m.Spawn()) _autogen_version(m.Spawn())
m.Cmd(cli.SYSTEM, GO, "get", "shylinux.com/x/ice") m.Cmd(cli.SYSTEM, GO, "get", "shylinux.com/x/ice")
cli.PushStream(m)
// 执行编译 // 执行编译
cli.PushStream(m)
main, file, goos, arch := _compile_target(m, arg...) main, file, goos, arch := _compile_target(m, arg...)
m.Optionv(cli.CMD_ENV, kit.Simple(m.Configv(cli.ENV), cli.HOME, kit.Env(cli.HOME), cli.PATH, kit.Env(cli.PATH), cli.GOOS, goos, cli.GOARCH, arch)) m.Optionv(cli.CMD_ENV, kit.Simple(m.Configv(cli.ENV), cli.HOME, kit.Env(cli.HOME), cli.PATH, kit.Env(cli.PATH), cli.GOOS, goos, cli.GOARCH, arch))
if msg := m.Cmd(cli.SYSTEM, GO, cli.BUILD, "-o", file, main, ice.SRC_VERSION_GO, ice.SRC_BINPACK_GO); !cli.IsSuccess(msg) { if msg := m.Cmd(cli.SYSTEM, GO, cli.BUILD, "-o", file, main, ice.SRC_VERSION_GO, ice.SRC_BINPACK_GO); !cli.IsSuccess(msg) {
m.Copy(msg) m.Copy(msg)
return return
} }
m.Option(cli.CMD_OUTPUT, "")
// 编译成功 // 编译成功
m.Log_EXPORT(nfs.SOURCE, main, nfs.TARGET, file) m.Log_EXPORT(nfs.SOURCE, main, nfs.TARGET, file)

View File

@ -83,7 +83,10 @@ func _go_doc(m *ice.Message, mod string, pkg string) *ice.Message {
func _go_exec(m *ice.Message, arg ...string) { func _go_exec(m *ice.Message, arg ...string) {
if m.Option("some") == "run" { if m.Option("some") == "run" {
m.Cmdy(cli.SYSTEM, "./bin/ice.bin", ice.GetFileCmd(path.Join(arg[2], arg[1]))) args := []string{"./bin/ice.bin", ice.GetFileCmd(path.Join(arg[2], arg[1]))}
m.Cmdy(cli.SYSTEM, args)
m.StatusTime("args", kit.Join(args, " "))
m.Debug(m.FormatsMeta())
return return
} }
if m.Option(mdb.TEXT) == "" { if m.Option(mdb.TEXT) == "" {

View File

@ -33,7 +33,7 @@ func _inner_exec(m *ice.Message, ext, file, dir string, arg ...string) {
if !m.Right(dir, file) { if !m.Right(dir, file) {
return // 没有权限 return // 没有权限
} }
defer m.StatusTime() // defer m.StatusTime()
if m.Cmdy(mdb.ENGINE, ext, file, dir, arg); m.Result() != "" { if m.Cmdy(mdb.ENGINE, ext, file, dir, arg); m.Result() != "" {
return // 执行成功 return // 执行成功
} }

View File

@ -15,6 +15,7 @@ import (
func _js_main_script(m *ice.Message, arg ...string) (res []string) { func _js_main_script(m *ice.Message, arg ...string) (res []string) {
if res = append(res, kit.Format(`global.plugin = "%s"`, kit.Path(arg[2], arg[1]))); len(ice.Info.Pack) == 0 { if res = append(res, kit.Format(`global.plugin = "%s"`, kit.Path(arg[2], arg[1]))); len(ice.Info.Pack) == 0 {
res = append(res, kit.Format(`require("%s")`, kit.Path("usr/volcanos/proto.js"))) res = append(res, kit.Format(`require("%s")`, kit.Path("usr/volcanos/proto.js")))
res = append(res, kit.Format(`require("%s")`, kit.Path("usr/volcanos/publish/client/nodejs/proto.js")))
} else { } else {
for _, file := range []string{"proto.js", "frame.js", "lib/base.js", "lib/core.js", "lib/misc.js", "lib/page.js", "publish/client/nodejs/proto.js"} { for _, file := range []string{"proto.js", "frame.js", "lib/base.js", "lib/core.js", "lib/misc.js", "lib/page.js", "publish/client/nodejs/proto.js"} {
res = append(res, `_can_name = "./`+file+`"`) res = append(res, `_can_name = "./`+file+`"`)
@ -29,6 +30,14 @@ func _js_main_script(m *ice.Message, arg ...string) (res []string) {
} }
func _js_exec(m *ice.Message, arg ...string) { func _js_exec(m *ice.Message, arg ...string) {
if m.Option("some") == "run" {
args := kit.Simple("node", "-e", kit.Join(_js_main_script(m, arg...), ice.NL))
m.Cmdy(cli.SYSTEM, args)
m.StatusTime("args", kit.Join([]string{"./bin/ice.bin", "web.code.js.js", "exec", path.Join(arg[2], arg[1])}, " "))
m.Debug(m.FormatsMeta())
return
}
if m.Option(mdb.NAME) == ice.PT { if m.Option(mdb.NAME) == ice.PT {
switch m.Option(mdb.TYPE) { switch m.Option(mdb.TYPE) {
case "msg": case "msg":
@ -70,11 +79,16 @@ func init() {
} }
} }
m.Display(path.Join("/require", path.Join(arg[2], arg[1]))) m.Display(path.Join("/require", path.Join(arg[2], arg[1])))
m.ProcessCommand(kit.Select("can.code.inner.plugin", key), kit.Simple()) m.ProcessCommand(kit.Select("can.code.inner._plugin", key), kit.Simple())
}}, }},
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
_js_exec(m, arg...) _js_exec(m, arg...)
}}, }},
"exec": {Hand: func(m *ice.Message, arg ...string) {
m.Option("some", "run")
_js_exec(m, "", arg[0], "")
}},
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
if arg[0] == mdb.FOREACH { if arg[0] == mdb.FOREACH {
return return

View File

@ -89,6 +89,8 @@ func _vimer_inputs(m *ice.Message, arg ...string) {
case web.DREAM: case web.DREAM:
m.Cmdy(web.DREAM, mdb.INPUTS, arg) m.Cmdy(web.DREAM, mdb.INPUTS, arg)
case AUTOGEN:
m.Cmdy(AUTOGEN, mdb.INPUTS, arg)
} }
} }
@ -145,13 +147,20 @@ func _vimer_go_complete(m *ice.Message, name string, arg ...string) *ice.Message
const VIMER = "vimer" const VIMER = "vimer"
func init() { func init() {
Index.Merge(&ice.Context{Commands: ice.Commands{ Index.Merge(&ice.Context{
Configs: ice.Configs{
VIMER: {Name: VIMER, Help: "编辑器", Value: kit.Data()},
},
Commands: ice.Commands{
VIMER: {Name: "vimer path=src/ file=main.go line=1 list", Help: "编辑器", Meta: kit.Dict(ice.DisplayLocal("", INNER)), Actions: ice.Actions{ VIMER: {Name: "vimer path=src/ file=main.go line=1 list", Help: "编辑器", Meta: kit.Dict(ice.DisplayLocal("", INNER)), Actions: ice.Actions{
nfs.SAVE: {Name: "save type file path", Help: "保存", Hand: func(m *ice.Message, arg ...string) { nfs.SAVE: {Name: "save type file path", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
m.Option(nfs.CONTENT, kit.Select(_vimer_defs(m, kit.Ext(m.Option(nfs.FILE))), m.Option(nfs.CONTENT))) m.Option(nfs.CONTENT, kit.Select(_vimer_defs(m, kit.Ext(m.Option(nfs.FILE))), m.Option(nfs.CONTENT)))
m.Cmdy(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE))) m.Cmdy(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
}}, }},
AUTOGEN: {Name: "create main=src/main.go zone name=hi help=示例 type=Zone,Hash,Lists,Data,Code key", Help: "模块", Hand: func(m *ice.Message, arg ...string) { nfs.TRASH: {Name: "trash path", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(nfs.TRASH, arg[0])
}},
AUTOGEN: {Name: "create name=hi help=示例 type=Zone,Hash,Lists,Data,Code main=main.go zone key", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(AUTOGEN, mdb.CREATE, arg) m.Cmdy(AUTOGEN, mdb.CREATE, arg)
}}, }},
COMPILE: {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) { COMPILE: {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) {
@ -209,6 +218,11 @@ func init() {
m.ProcessInner() m.ProcessInner()
m.ToastSuccess() m.ToastSuccess()
}}, }},
}, Hand: func(m *ice.Message, arg ...string) { m.Cmdy(INNER, arg) }}, }, Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(INNER, arg)
m.Option("plug", m.Config("show.plug"))
m.Option("exts", m.Config("show.exts"))
m.Option("tabs", m.Config("show.tabs"))
}},
}}) }})
} }