1
0
forked from x/icebergs
This commit is contained in:
harveyshao 2021-09-14 17:23:09 +08:00
parent 9bbb80c656
commit 54587b39ea
7 changed files with 43 additions and 30 deletions

View File

@ -148,7 +148,9 @@ require miss.sh
ish_miss_prepare_develop
ish_miss_prepare_install
ish_miss_prepare release
# ish_miss_prepare wubi-dict
# ish_miss_prepare word-dict
ish_miss_prepare_contexts
# ish_miss_prepare_intshell

View File

@ -12,6 +12,7 @@ import (
"shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/tcp"
kit "shylinux.com/x/toolkits"
)
@ -292,6 +293,12 @@ func init() {
m.RenderIndex(SERVE, ice.INTSHELL, arg...)
}},
"/publish/": {Name: "/publish/", Help: "私有云", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if arg[0] == ice.ORDER_JS {
if p := path.Join(ice.USR_PUBLISH, ice.ORDER_JS); m.PodCmd(nfs.CAT, p) {
m.RenderResult()
return
}
}
_share_local(m, m.Conf(SERVE, kit.Keym(ice.PUBLISH)), path.Join(arg...))
}},
"/require/": {Name: "/require/", Help: "公有云", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {

View File

@ -178,6 +178,7 @@ func _spide_part(m *ice.Message, arg ...string) (io.Reader, string) {
}
if strings.HasPrefix(arg[i+1], "@") {
if s, e := os.Stat(arg[i+1][1:]); e == nil {
m.Debug("local: %s cache: %s", s.ModTime(), cache)
if s.ModTime().Before(cache) {
break
}
@ -185,7 +186,9 @@ func _spide_part(m *ice.Message, arg ...string) (io.Reader, string) {
if f, e := os.Open(arg[i+1][1:]); m.Assert(e) {
defer f.Close()
if p, e := mp.CreateFormFile(arg[i], path.Base(arg[i+1][1:])); m.Assert(e) {
io.Copy(p, f)
if n, e := io.Copy(p, f); m.Assert(e) {
m.Debug("upload: %s %d", arg[i+1], n)
}
}
}
} else {

View File

@ -70,6 +70,12 @@ func (web *Frame) Start(m *ice.Message, arg ...string) bool {
})
web.m, web.Server = m, &http.Server{Handler: web}
switch cb := m.Optionv(kit.Keycb(SERVE)).(type) {
case func(http.Handler):
cb(web)
return true
}
m.Option(kit.Keycb(tcp.LISTEN), func(l net.Listener) {
m.Cmdy(mdb.INSERT, SERVE, "", mdb.HASH, arg, kit.MDB_STATUS, tcp.START, kit.MDB_PROTO, m.Option(kit.MDB_PROTO), SPIDE_DEV, m.Option(SPIDE_DEV))
defer m.Cmd(mdb.MODIFY, SERVE, "", mdb.HASH, kit.MDB_NAME, m.Option(kit.MDB_NAME), kit.MDB_STATUS, tcp.STOP)
@ -88,8 +94,7 @@ func (web *Frame) Close(m *ice.Message, arg ...string) bool {
const WEB = "web"
var Index = &ice.Context{Name: WEB, Help: "网络模块",
Commands: map[string]*ice.Command{
var Index = &ice.Context{Name: WEB, Help: "网络模块", Commands: map[string]*ice.Command{
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Load()
m.Conf(SPACE, kit.MDB_HASH, "")
@ -107,8 +112,7 @@ var Index = &ice.Context{Name: WEB, Help: "网络模块",
m.Done(value[kit.MDB_STATUS] == tcp.START)
})
}},
},
}
}}
func init() {
ice.Index.Register(Index, &Frame{},

View File

@ -22,6 +22,7 @@ func _defs(m *ice.Message, args ...string) {
}
func _autogen_script(m *ice.Message, dir string) {
buf, _ := kit.Render(`chapter "{{.Option "name"}}"
field "{{.Option "help"}}" {{.Option "key"}}
`, m)
m.Cmd(nfs.DEFS, dir, string(buf))
@ -38,17 +39,15 @@ import (
type {{.Option "name"}} struct {
ice.{{.Option "type"}}
list string {{.Option "list"}}
}
func (h {{.Option "name"}}) List(m *ice.Message, arg ...string) {
h.{{.Option "type"}}.List(m, arg...)
}
func init() {
ice.Cmd("{{.Option "key"}}", &{{.Option "name"}}{}, []*ice.Show{
{Name: "{{.Option "list"}}", Help: "{{.Option "help"}}"},
})
}
func init() { ice.Cmd("{{.Option "key"}}", &{{.Option "name"}}{}) }
`, m)
m.Cmd(nfs.SAVE, dir, string(buf))
}
@ -157,6 +156,7 @@ func init() {
case "Data":
_defs(m, "list", "list path auto upload")
}
m.Option("list", kit.Format("`name:\"%s\" help:\"%s\"`", m.Option("list"), m.Option("help")))
if p := path.Join(kit.SSH_SRC, m.Option(kit.MDB_ZONE), kit.Keys(m.Option(kit.MDB_NAME), SHY)); !kit.FileExists(p) {
_autogen_script(m, p)

View File

@ -150,7 +150,7 @@ func init() {
echo "hello world"
`,
JS, `Volcanos("onengine", {_init: function(can, sub) {
can.base.Log("hello volcanos world")
can.misc.Log("hello volcanos world")
}, river: {
}})

View File

@ -33,10 +33,6 @@ func init() {
nfs.SAVE: {Name: "save type file path", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(nfs.SAVE, path.Join(m.Option(kit.MDB_PATH), m.Option(kit.MDB_FILE)))
}},
BINPACK: {Name: "binpack", Help: "打包:生成 src/binpack.go", Hand: func(m *ice.Message, arg ...string) {
_autogen_version(m)
m.Cmd(BINPACK, mdb.CREATE)
}},
AUTOGEN: {Name: "create main=src/main.go@key key= zone= type=Zone,Hash,List,Data name=hi list= help=", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(AUTOGEN, mdb.CREATE, arg)
}},
@ -44,6 +40,7 @@ func init() {
if p := os.Getenv(cli.PATH); !strings.Contains(p, "usr/local/go/bin") {
m.Option(cli.CMD_ENV, cli.PATH, kit.Path("usr/local/go/bin")+":"+p)
}
_autogen_version(m)
if m.Cmdy(cli.SYSTEM, "go", "build", "-v", "-o", "bin/ice.bin", "src/main.go", "src/version.go"); m.Append(cli.CMD_CODE) == "0" {
m.Cmd("exit", "1")
}