mirror of
https://shylinux.com/x/icebergs
synced 2025-05-01 03:09:21 +08:00
opt some
This commit is contained in:
parent
da6498a52e
commit
55a6eccb46
@ -25,7 +25,7 @@ func _command_list(m *ice.Message, name string) {
|
|||||||
|
|
||||||
// 命令详情
|
// 命令详情
|
||||||
m.Spawn(m.Source()).Search(name, func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
|
m.Spawn(m.Source()).Search(name, func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
|
||||||
m.Push(kit.MDB_KEY, s.Cap(ice.CTX_FOLLOW))
|
m.Push(kit.MDB_INDEX, s.Cap(ice.CTX_FOLLOW))
|
||||||
m.Push(kit.MDB_NAME, kit.Format(cmd.Name))
|
m.Push(kit.MDB_NAME, kit.Format(cmd.Name))
|
||||||
m.Push(kit.MDB_HELP, kit.Format(cmd.Help))
|
m.Push(kit.MDB_HELP, kit.Format(cmd.Help))
|
||||||
m.Push(kit.MDB_META, kit.Formats(cmd.Meta))
|
m.Push(kit.MDB_META, kit.Formats(cmd.Meta))
|
||||||
|
@ -170,5 +170,6 @@ func init() {
|
|||||||
"/share/repos/": {Name: "/share/repos/", Help: "代码库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"/share/repos/": {Name: "/share/repos/", Help: "代码库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
_share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...)
|
_share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...)
|
||||||
}},
|
}},
|
||||||
}})
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
|
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
|
"github.com/shylinux/icebergs/base/tcp"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -27,10 +28,10 @@ func _spide_create(m *ice.Message, name, address string) {
|
|||||||
dir, file := path.Split(uri.EscapedPath())
|
dir, file := path.Split(uri.EscapedPath())
|
||||||
m.Echo(m.Rich(SPIDE, nil, kit.Dict(
|
m.Echo(m.Rich(SPIDE, nil, kit.Dict(
|
||||||
SPIDE_COOKIE, kit.Dict(), SPIDE_HEADER, kit.Dict(), SPIDE_CLIENT, kit.Dict(
|
SPIDE_COOKIE, kit.Dict(), SPIDE_HEADER, kit.Dict(), SPIDE_CLIENT, kit.Dict(
|
||||||
"name", name, "url", address, "method", SPIDE_POST,
|
kit.MDB_NAME, name, "url", address, SPIDE_METHOD, SPIDE_POST,
|
||||||
"protocol", uri.Scheme, "hostname", uri.Host,
|
tcp.PROTOCOL, uri.Scheme, tcp.HOSTNAME, uri.Host,
|
||||||
"path", dir, "file", file, "query", uri.RawQuery,
|
kit.MDB_PATH, dir, kit.MDB_FILE, file, "query", uri.RawQuery,
|
||||||
"timeout", "600s", LOGHEADERS, false,
|
kit.MDB_TIMEOUT, "600s", LOGHEADERS, false,
|
||||||
),
|
),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
@ -82,7 +83,7 @@ func _spide_show(m *ice.Message, arg ...string) {
|
|||||||
_spide_head(m, req, head, value)
|
_spide_head(m, req, head, value)
|
||||||
|
|
||||||
// 发送请求
|
// 发送请求
|
||||||
res, e := _spide_send(m, req, kit.Format(client["timeout"]))
|
res, e := _spide_send(m, req, kit.Format(client[kit.MDB_TIMEOUT]))
|
||||||
if m.Warn(e != nil, ice.ErrNotFound, e) {
|
if m.Warn(e != nil, ice.ErrNotFound, e) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -284,9 +285,9 @@ const (
|
|||||||
|
|
||||||
SPIDE_FORM = "form"
|
SPIDE_FORM = "form"
|
||||||
SPIDE_PART = "part"
|
SPIDE_PART = "part"
|
||||||
|
SPIDE_JSON = "json"
|
||||||
SPIDE_DATA = "data"
|
SPIDE_DATA = "data"
|
||||||
SPIDE_FILE = "file"
|
SPIDE_FILE = "file"
|
||||||
SPIDE_JSON = "json"
|
|
||||||
SPIDE_BODY = "body"
|
SPIDE_BODY = "body"
|
||||||
|
|
||||||
SPIDE_RES = "content_data"
|
SPIDE_RES = "content_data"
|
||||||
@ -308,7 +309,6 @@ const (
|
|||||||
ADDRESS = "address"
|
ADDRESS = "address"
|
||||||
REQUEST = "request"
|
REQUEST = "request"
|
||||||
RESPONSE = "response"
|
RESPONSE = "response"
|
||||||
PROTOCOL = "protocol"
|
|
||||||
|
|
||||||
CLIENT_NAME = "client.name"
|
CLIENT_NAME = "client.name"
|
||||||
LOGHEADERS = "logheaders"
|
LOGHEADERS = "logheaders"
|
||||||
@ -318,31 +318,22 @@ const SPIDE = "spide"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
SPIDE: {Name: SPIDE, Help: "蜘蛛侠", Value: kit.Data(kit.MDB_SHORT, CLIENT_NAME)},
|
SPIDE: {Name: SPIDE, Help: "蜘蛛侠", Value: kit.Data(
|
||||||
|
kit.MDB_SHORT, CLIENT_NAME, kit.MDB_SHORT, "time,client.name,client.url",
|
||||||
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
SPIDE: {Name: "spide client.name action=raw,msg,save,cache method=GET,PUT,POST,DELETE url format=form,part,data,file,json arg 执行:button create", Help: "蜘蛛侠", Action: map[string]*ice.Action{
|
SPIDE: {Name: "spide client.name action=raw,msg,save,cache method=GET,PUT,POST,DELETE url format=form,part,json,data,file arg 执行:button create", Help: "蜘蛛侠", Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
mdb.CREATE: {Name: "create name address", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create name address", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if arg[0] != kit.MDB_NAME {
|
|
||||||
m.Option(kit.MDB_NAME, arg[0])
|
|
||||||
m.Option(ADDRESS, arg[1])
|
|
||||||
}
|
|
||||||
_spide_create(m, m.Option(kit.MDB_NAME), m.Option(ADDRESS))
|
_spide_create(m, m.Option(kit.MDB_NAME), m.Option(ADDRESS))
|
||||||
}},
|
}},
|
||||||
mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Cmdy(mdb.MODIFY, SPIDE, "", mdb.HASH, CLIENT_NAME, m.Option(CLIENT_NAME), arg)
|
|
||||||
}},
|
|
||||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmdy(mdb.DELETE, SPIDE, "", mdb.HASH, CLIENT_NAME, m.Option(CLIENT_NAME))
|
|
||||||
}},
|
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") {
|
if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") {
|
||||||
m.Fields(len(kit.Slice(arg, 0, 1)), "time,client.name,client.url")
|
m.Fields(len(kit.Slice(arg, 0, 1)), m.Conf(SPIDE, kit.META_FIELD))
|
||||||
m.Cmdy(mdb.SELECT, SPIDE, "", mdb.HASH, CLIENT_NAME, arg)
|
m.Cmdy(mdb.SELECT, m.PrefixKey(), "", mdb.HASH, CLIENT_NAME, arg)
|
||||||
m.PushAction(mdb.REMOVE)
|
m.PushAction(mdb.REMOVE)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_spide_show(m, arg...)
|
_spide_show(m, arg...)
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/shylinux/icebergs/base/cli"
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
"github.com/shylinux/icebergs/base/ctx"
|
"github.com/shylinux/icebergs/base/ctx"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
"github.com/shylinux/icebergs/base/nfs"
|
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
)
|
)
|
||||||
@ -205,47 +204,5 @@ func init() {
|
|||||||
// 执行命令
|
// 执行命令
|
||||||
_action_show(m, arg[0], arg[1], arg[2], arg[3:]...)
|
_action_show(m, arg[0], arg[1], arg[2], arg[3:]...)
|
||||||
}},
|
}},
|
||||||
|
|
||||||
"/cmd/": {Name: "/cmd/", Help: "命令", Action: map[string]*ice.Action{
|
|
||||||
ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if len(arg) == 0 {
|
|
||||||
m.Push("index", kit.Select("cmd"))
|
|
||||||
m.Push("args", "")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Cmdy(ctx.COMMAND, arg[0])
|
|
||||||
}},
|
|
||||||
cli.RUN: {Name: "command", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmdy(arg)
|
|
||||||
}},
|
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
sp := m.Conf(web.SERVE, kit.Keym(ice.VOLCANOS, kit.MDB_PATH))
|
|
||||||
if strings.HasSuffix(m.R.URL.Path, "/") {
|
|
||||||
m.RenderDownload(path.Join(sp, "page/cmd.html"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.RenderDownload(path.Join(sp, path.Join(arg...)))
|
|
||||||
}},
|
|
||||||
"cmd": {Name: "cmd path auto up", Help: "命令", Action: map[string]*ice.Action{
|
|
||||||
"up": {Name: "up", Help: "上一级", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if strings.TrimPrefix(m.R.URL.Path, "/cmd") == "/" {
|
|
||||||
m.Cmdy("cmd")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if strings.HasSuffix(m.R.URL.Path, "/") {
|
|
||||||
m.Process("_location", "../")
|
|
||||||
} else {
|
|
||||||
m.Process("_location", "./")
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
if len(arg) > 0 {
|
|
||||||
m.Process("_location", arg[0])
|
|
||||||
return
|
|
||||||
}
|
|
||||||
sup := m.Conf(web.SERVE, kit.Keym(ice.VOLCANOS, kit.MDB_PATH))
|
|
||||||
m.Option(nfs.DIR_ROOT, path.Join(sup, strings.TrimPrefix(path.Dir(m.R.URL.Path), "/cmd")))
|
|
||||||
m.Cmdy(nfs.DIR, arg)
|
|
||||||
}},
|
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user