1
0
mirror of https://shylinux.com/x/icebergs synced 2025-05-02 19:47:02 +08:00
This commit is contained in:
shylinux 2021-10-12 15:53:40 +08:00
parent db621f3348
commit 7a72e0cd72
5 changed files with 29 additions and 25 deletions

View File

@ -180,7 +180,7 @@ func init() {
m.Cmd(code.PUBLISH, mdb.CREATE, kit.MDB_FILE, ice.BIN_ICE_SH)
m.Cmd(code.PUBLISH, mdb.CREATE, kit.MDB_FILE, ice.BIN_ICE_BIN)
}},
cli.START: {Name: "start name repos template", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
cli.START: {Name: "start name=hi repos template", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(m.Space(m.Option(cli.POD)), web.DREAM, cli.START, arg)
}},

View File

@ -9,6 +9,7 @@ import (
"shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/ssh"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
)
@ -52,11 +53,6 @@ func init() { ice.Cmd("{{.Option "key"}}", {{.Option "name"}}{}) }
m.Cmd(nfs.SAVE, dir, string(buf))
}
func _autogen_import(m *ice.Message, main string, ctx string, mod string) (list []string) {
m.Cmd(nfs.DEFS, ice.GO_MOD, kit.Format(`module %s
go 1.11
`, path.Base(kit.Path(""))))
m.Cmd(nfs.DEFS, main, `package main
import "shylinux.com/x/ice"
@ -82,6 +78,11 @@ func main() { print(ice.Run()) }
return
}
func _autogen_mod(m *ice.Message, file string) (mod string) {
m.Cmd(nfs.DEFS, ice.GO_MOD, kit.Format(`module %s
go 1.11
`, path.Base(kit.Path(""))))
m.Cmd(nfs.CAT, file, func(line string, index int) {
if strings.HasPrefix(line, "module") {
mod = strings.Split(line, " ")[1]
@ -178,7 +179,7 @@ func init() {
_autogen_version(m)
m.Cmd(BINPACK, mdb.CREATE)
}},
"script": {Name: "script", Help: "脚本:生成 etc/miss.sh", Hand: func(m *ice.Message, arg ...string) {
ssh.SCRIPT: {Name: "script", Help: "脚本:生成 etc/miss.sh", Hand: func(m *ice.Message, arg ...string) {
_autogen_miss(m)
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {

View File

@ -80,7 +80,7 @@ const BINPACK = "binpack"
func init() {
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
BINPACK: {Name: "binpack path auto create", Help: "打包", Action: map[string]*ice.Action{
BINPACK: {Name: "binpack path auto create remove export", Help: "打包", Action: map[string]*ice.Action{
mdb.CREATE: {Name: "create", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
if pack, p, e := kit.Create(ice.SRC_BINPACK); m.Assert(e) {
defer pack.Close()
@ -107,6 +107,18 @@ func init() {
m.Echo(p)
}
}},
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
ice.Info.BinPack = map[string][]byte{}
}},
mdb.EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
for key, value := range ice.Info.BinPack {
if strings.HasPrefix(key, "/") {
key = ice.USR_VOLCANOS + key
}
m.Warn(os.MkdirAll(path.Dir(key), ice.MOD_DIR) != nil, "key: ", key)
m.Warn(ioutil.WriteFile(key, value, ice.MOD_FILE) != nil, "key: ", key)
}
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
for k, v := range ice.Info.BinPack {
m.Push(kit.MDB_NAME, k)

View File

@ -149,11 +149,7 @@ func init() {
SH, `#!/bin/bash
echo "hello world"
`,
JS, `Volcanos("onengine", {_init: function(can, sub) {
can.misc.Log("hello volcanos world")
}, river: {
}})
JS, `Volcanos("onengine", {})
`,
)},
}})

19
init.go
View File

@ -158,19 +158,14 @@ var Info = struct {
}
func Dump(w io.Writer, name string, cb func(string)) bool {
if b, ok := Info.BinPack[name]; ok {
if cb != nil {
cb(name)
for _, key := range []string{name, strings.TrimPrefix(name, USR_VOLCANOS)} {
if b, ok := Info.BinPack[key]; ok {
if cb != nil {
cb(name)
}
w.Write(b)
return true
}
w.Write(b)
return true
}
if b, ok := Info.BinPack[strings.TrimPrefix(name, USR_VOLCANOS)]; ok {
if cb != nil {
cb(name)
}
w.Write(b)
return true
}
return false
}