forked from x/icebergs
add some
This commit is contained in:
parent
931adfcdc5
commit
5bdef43436
@ -142,6 +142,8 @@ const (
|
||||
CMD_OUT = "cmd_out"
|
||||
|
||||
MAN = "man"
|
||||
RUN = "run"
|
||||
KILL = "kill"
|
||||
FIND = "find"
|
||||
GREP = "grep"
|
||||
EXEC = "exec"
|
||||
|
@ -119,13 +119,14 @@ func PodCmd(m *ice.Message, arg ...ice.Any) bool {
|
||||
func Run(m *ice.Message, arg ...string) {
|
||||
kit.If(!PodCmd(m, arg) && aaa.Right(m, arg), func() { m.Cmdy(arg) })
|
||||
}
|
||||
func Command(m *ice.Message, arg ...string) {
|
||||
kit.If(!PodCmd(m, COMMAND, arg), func() { m.Cmdy(COMMAND, arg) })
|
||||
}
|
||||
func CmdHandler(args ...ice.Any) ice.Handler {
|
||||
return func(m *ice.Message, arg ...string) { m.Cmdy(args...) }
|
||||
}
|
||||
func CmdAction(args ...ice.Any) ice.Actions {
|
||||
return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(args...), ice.RUN: {Hand: Run},
|
||||
COMMAND: {Hand: func(m *ice.Message, arg ...string) { kit.If(!PodCmd(m, COMMAND, arg), func() { m.Cmdy(COMMAND, arg) }) }},
|
||||
}
|
||||
return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(args...), ice.RUN: {Hand: Run}, COMMAND: {Hand: Command}}
|
||||
}
|
||||
func CmdList(m *ice.Message) *ice.Message {
|
||||
return m.Cmdy(COMMAND, mdb.SEARCH, COMMAND, ice.OptionFields(INDEX))
|
||||
|
@ -41,6 +41,12 @@ func DisplayStoryJSON(m displayMessage, arg ...ice.Any) displayMessage {
|
||||
func DisplayStorySpide(m displayMessage, arg ...ice.Any) displayMessage {
|
||||
return DisplayStory(m, "spide", arg...)
|
||||
}
|
||||
func DisplayStudio(m *ice.Message, cmd ...string) displayMessage {
|
||||
for i, k := range cmd {
|
||||
cmd[i] = m.Prefix(k)
|
||||
}
|
||||
return DisplayStory(m.Cmdy(COMMAND, cmd), "studio.js")
|
||||
}
|
||||
func DisplayLocal(m displayMessage, file string, arg ...ice.Any) displayMessage {
|
||||
kit.If(file == "", func() { file = path.Join(kit.PathName(5), kit.Keys(kit.FileName(5), nfs.JS)) })
|
||||
kit.If(isLocalFile(file), func() { file = path.Join(ice.PLUGIN_LOCAL, file) })
|
||||
|
@ -106,6 +106,8 @@ const (
|
||||
PRUNES = "prunes"
|
||||
EXPORT = "export"
|
||||
IMPORT = "import"
|
||||
PRUNE = "prune"
|
||||
RENAME = "rename"
|
||||
|
||||
DETAIL = "detail"
|
||||
FIELDS = "fields"
|
||||
|
@ -58,6 +58,14 @@ func init() {
|
||||
m.Push(arg[0], strings.Replace(value["local"], "0.0.0.0", "127.0.0.1", 1))
|
||||
}
|
||||
})
|
||||
case "port":
|
||||
m.Cmd(PORT, "socket", func(value ice.Maps) {
|
||||
switch value["status"] {
|
||||
case "LISTEN":
|
||||
m.Push(arg[0], strings.TrimPrefix(value["local"], "0.0.0.0:"))
|
||||
m.Push(mdb.NAME, "listen")
|
||||
}
|
||||
})
|
||||
}
|
||||
}},
|
||||
"socket": {Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -193,6 +193,9 @@ func init() {
|
||||
})
|
||||
}},
|
||||
cli.SYSTEM: {Help: "系统", Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, "System Settings.app") }},
|
||||
"publicip": {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(kit.Formats(PublicIP(m)))
|
||||
}},
|
||||
"dark": {Help: "主题", Hand: func(m *ice.Message, arg ...string) {
|
||||
if !tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
||||
return
|
||||
|
@ -289,13 +289,19 @@ func init() {
|
||||
}
|
||||
|
||||
func HostPort(m *ice.Message, host, port string, arg ...string) string {
|
||||
if port == "443" {
|
||||
return kit.Format("https://%s", host)
|
||||
} else if port == "80" {
|
||||
return kit.Format("http://%s", host)
|
||||
} else {
|
||||
return kit.Format("http://%s:%s", host, port)
|
||||
if host == "" {
|
||||
host = kit.ParseURL(UserHost(m)).Hostname()
|
||||
}
|
||||
if port == "80" {
|
||||
return kit.Format("http://%s", host)
|
||||
} else if port == "443" {
|
||||
return kit.Format("https://%s", host)
|
||||
} else {
|
||||
return kit.Format("%s://%s:%s", kit.ParseURL(UserHost(m)).Scheme, host, port)
|
||||
}
|
||||
}
|
||||
func PublicIP(m *ice.Message) ice.Any {
|
||||
return SpideGet(m, "http://ip-api.com/json")
|
||||
}
|
||||
func SpideGet(m *ice.Message, arg ...ice.Any) ice.Any {
|
||||
return kit.UnMarshal(m.Cmdx(http.MethodGet, arg))
|
||||
|
Loading…
x
Reference in New Issue
Block a user