mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 09:34:05 +08:00
opt inner
This commit is contained in:
parent
caa1fb64c1
commit
432b543575
@ -55,7 +55,7 @@ func init() {
|
||||
SYSTEM: {Name: "system", Help: "系统命令", Value: kit.Data()},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
SYSTEM: {Name: "system cmd arg...", Help: "系统命令", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||
SYSTEM: {Name: "system cmd arg arg arg arg...", Help: "系统命令", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||
cmd := exec.Command(arg[0], arg[1:]...)
|
||||
|
||||
// 运行目录
|
||||
|
@ -26,7 +26,7 @@ func _c_tags(m *ice.Message, key string) {
|
||||
if _, e := os.Stat(path.Join(m.Option("_path"), ".tags")); e != nil {
|
||||
m.Cmd(cli.SYSTEM, "ctags", "-R", "-f", ".tags", "./")
|
||||
}
|
||||
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, "grep", key, ".tags"), "\n") {
|
||||
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, "grep", "^"+key, ".tags"), "\n") {
|
||||
ls := strings.SplitN(l, "\t", 2)
|
||||
if len(ls) < 2 {
|
||||
continue
|
||||
@ -53,7 +53,9 @@ func _c_tags(m *ice.Message, key string) {
|
||||
m.Sort("line", "int")
|
||||
}
|
||||
func _c_grep(m *ice.Message, key string) {
|
||||
m.Split(m.Cmd(cli.SYSTEM, "grep", "--exclude=.[a-z]*", "-rn", key, ".").Append(cli.CMD_OUT), "file:line:text", ":", "\n")
|
||||
m.Split(m.Cmd(cli.SYSTEM, "grep",
|
||||
"--exclude-dir=.git", "--exclude-dir=pluged",
|
||||
"--exclude=.[a-z]*", "-rn", key, ".").Append(cli.CMD_OUT), "file:line:text", ":", "\n")
|
||||
}
|
||||
func _c_help(m *ice.Message, section, key string) {
|
||||
p := m.Cmd(cli.SYSTEM, "man", section, key).Append(cli.CMD_OUT)
|
||||
@ -80,16 +82,24 @@ func _c_help(m *ice.Message, section, key string) {
|
||||
m.Push("line", 1)
|
||||
m.Push("text", string(res))
|
||||
}
|
||||
|
||||
const C = "c"
|
||||
const H = "h"
|
||||
const MAN1 = "man1"
|
||||
const MAN2 = "man2"
|
||||
const MAN3 = "man3"
|
||||
const MAN8 = "man8"
|
||||
|
||||
func init() {
|
||||
Index.Register(&ice.Context{Name: "c", Help: "c",
|
||||
Index.Register(&ice.Context{Name: C, Help: "c",
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, "h", "c", c.Cap(ice.CTX_FOLLOW))
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, "c", "c", c.Cap(ice.CTX_FOLLOW))
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, "man3", "c", c.Cap(ice.CTX_FOLLOW))
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, "man2", "c", c.Cap(ice.CTX_FOLLOW))
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, H, C, c.Cap(ice.CTX_FOLLOW))
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, C, C, c.Cap(ice.CTX_FOLLOW))
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, MAN3, C, c.Cap(ice.CTX_FOLLOW))
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, MAN2, C, c.Cap(ice.CTX_FOLLOW))
|
||||
}},
|
||||
"c": {Name: "c", Help: "c", Action: map[string]*ice.Action{
|
||||
C: {Name: C, Help: "c", Action: map[string]*ice.Action{
|
||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(cli.CMD_DIR, m.Option("_path"))
|
||||
_c_find(m, kit.Select("main", arg, 1))
|
||||
|
@ -55,6 +55,7 @@ func _inner_list(m *ice.Message, name string) {
|
||||
|
||||
if m.Set(ice.MSG_RESULT); strings.HasSuffix(name, "/") || _inner_source(m, name) {
|
||||
m.Option(nfs.DIR_DEEP, "true")
|
||||
m.Option(nfs.DIR_TYPE, nfs.TYPE_FILE)
|
||||
m.Cmdy(nfs.DIR, name, "path size time")
|
||||
return
|
||||
}
|
||||
@ -87,7 +88,8 @@ func _inner_plug(m *ice.Message, name string) {
|
||||
|
||||
m.Echo("{}")
|
||||
}
|
||||
func _inner_show(m *ice.Message, name string) {
|
||||
func _inner_show(m *ice.Message, dir, file string) {
|
||||
name := path.Join(dir, file)
|
||||
if _inner_sub(m, SHOW, name) {
|
||||
return
|
||||
}
|
||||
@ -102,10 +104,11 @@ func _inner_show(m *ice.Message, name string) {
|
||||
|
||||
switch m.Set(ice.MSG_RESULT); p {
|
||||
case "go":
|
||||
m.Option(cli.CMD_DIR, dir)
|
||||
if strings.HasSuffix(name, "test.go") {
|
||||
m.Cmdy(cli.SYSTEM, "go", "test", "-v", "./"+name)
|
||||
m.Cmdy(cli.SYSTEM, "go", "test", "-v", "./"+file)
|
||||
} else {
|
||||
m.Cmdy(cli.SYSTEM, "go", "run", "./"+name)
|
||||
m.Cmdy(cli.SYSTEM, "go", "run", "./"+file)
|
||||
}
|
||||
|
||||
case "csv":
|
||||
@ -127,7 +130,7 @@ func _inner_main(m *ice.Message, arg ...string) {
|
||||
m.Option(cli.CMD_DIR, arg[0])
|
||||
m.Echo(m.Cmdx(cli.SYSTEM, "go", "doc", key))
|
||||
|
||||
case "man3", "man2", "man1":
|
||||
case "man8", "man3", "man2", "man1":
|
||||
p := m.Cmdx(cli.SYSTEM, "man", strings.TrimPrefix(p, "man"), key)
|
||||
p = strings.Replace(p, "_\x08", "", -1)
|
||||
res := make([]byte, 0, len(p))
|
||||
@ -229,7 +232,7 @@ func init() {
|
||||
web.FavorList(m, "inner.run", "", "time", "id", "type", "name", "text")
|
||||
}},
|
||||
"run": {Name: "run path name", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
||||
_inner_show(m, path.Join("./", arg[0], arg[1]))
|
||||
_inner_show(m, arg[0], arg[1])
|
||||
}},
|
||||
PLUG: {Name: "plug path name", Help: "插件", Hand: func(m *ice.Message, arg ...string) {
|
||||
_inner_plug(m, path.Join("./", arg[0], arg[1]))
|
||||
|
42
core/code/js.go
Normal file
42
core/code/js.go
Normal file
@ -0,0 +1,42 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
)
|
||||
|
||||
func _js_find(m *ice.Message, key string) {
|
||||
for _, p := range strings.Split(m.Cmdx(cli.SYSTEM, "find", ".", "-name", key), "\n") {
|
||||
if p == "" {
|
||||
continue
|
||||
}
|
||||
m.Push("file", strings.TrimPrefix(p, "./"))
|
||||
m.Push("line", 1)
|
||||
m.Push("text", "")
|
||||
}
|
||||
}
|
||||
func _js_grep(m *ice.Message, key string) {
|
||||
m.Split(m.Cmd(cli.SYSTEM, "grep", "--exclude-dir=.git", "--exclude=.[a-z]*", "-rn", key, ".").Append(cli.CMD_OUT), "file:line:text", ":", "\n")
|
||||
}
|
||||
func init() {
|
||||
Index.Register(&ice.Context{Name: "js", Help: "js",
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, "js", "js", c.Cap(ice.CTX_FOLLOW))
|
||||
}},
|
||||
"js": {Name: "js", Help: "js", Action: map[string]*ice.Action{
|
||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(cli.CMD_DIR, m.Option("_path"))
|
||||
_js_find(m, kit.Select("main", arg, 1))
|
||||
_js_grep(m, kit.Select("main", arg, 1))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
|
||||
}},
|
||||
},
|
||||
}, nil)
|
||||
}
|
33
core/code/sh.go
Normal file
33
core/code/sh.go
Normal file
@ -0,0 +1,33 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
)
|
||||
|
||||
const SH = "sh"
|
||||
|
||||
func init() {
|
||||
Index.Register(&ice.Context{Name: SH, Help: "sh",
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, SH, SH, c.Cap(ice.CTX_FOLLOW))
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, "man1", SH, c.Cap(ice.CTX_FOLLOW))
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, "man8", SH, c.Cap(ice.CTX_FOLLOW))
|
||||
}},
|
||||
SH: {Name: SH, Help: "sh", Action: map[string]*ice.Action{
|
||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(cli.CMD_DIR, m.Option("_path"))
|
||||
_c_find(m, kit.Select("main", arg, 1))
|
||||
_c_help(m, "1", kit.Select("main", arg, 1))
|
||||
_c_help(m, "8", kit.Select("main", arg, 1))
|
||||
_c_grep(m, kit.Select("main", arg, 1))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
|
||||
}},
|
||||
},
|
||||
}, nil)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user