mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
opt some
This commit is contained in:
parent
c161d739f4
commit
1382ed1ff3
@ -184,7 +184,7 @@ const RUNTIME = "runtime"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
RUNTIME: {Name: "runtime info=ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,meminfo,bootinfo,api,cli,cmd,env auto", Help: "运行环境", Actions: ice.Actions{
|
||||
RUNTIME: {Name: "runtime info=ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,bootinfo,api,cli,cmd,env auto", Help: "运行环境", Actions: ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
cs := m.Target().Configs
|
||||
if _, ok := cs[RUNTIME]; !ok {
|
||||
|
@ -91,6 +91,11 @@ func init() {
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.Prefix(COMMAND))
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, COMMAND)
|
||||
TravelCmd(m, func(key, file, line string) {
|
||||
if strings.Contains(file, "icebergs") {
|
||||
AddFileCmd(file, key)
|
||||
}
|
||||
})
|
||||
}},
|
||||
mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[0] == m.CommandKey() || len(arg) > 1 && arg[1] != "" {
|
||||
@ -199,9 +204,9 @@ func AddFileCmd(dir, key string) {
|
||||
}
|
||||
func GetFileCmd(dir string) string {
|
||||
if strings.HasPrefix(dir, "usr/") {
|
||||
p := ice.Pulse.Cmdx("cli.system", "git", "config", "remote.origin.url", kit.Dict("cmd_dir", path.Dir(dir)))
|
||||
p = strings.Replace(strings.TrimSpace(p), "https://", "/require/", 1)
|
||||
dir = path.Join(p, strings.Join(strings.Split(dir, "/")[2:], "/"))
|
||||
// p := ice.Pulse.Cmdx("cli.system", "git", "config", "remote.origin.url", kit.Dict("cmd_dir", path.Dir(dir)))
|
||||
// p = strings.Replace(strings.TrimSpace(p), "https://", "/require/", 1)
|
||||
// dir = path.Join(p, strings.Join(strings.Split(dir, "/")[2:], "/"))
|
||||
}
|
||||
if strings.HasPrefix(dir, ".ish/pluged/") {
|
||||
dir = strings.Replace(dir, ".ish/pluged/", "/require/", 1)
|
||||
@ -242,7 +247,7 @@ func TravelCmd(m *ice.Message, cb func(key, file, line string)) {
|
||||
|
||||
ls := kit.Split(cmd.GetFileLine(), ":")
|
||||
if len(ls) > 1 {
|
||||
cb(key, strings.TrimPrefix(ls[0], kit.Path("")+ice.PS), ls[1])
|
||||
cb(kit.Keys(s.Cap(ice.CTX_FOLLOW), key), strings.TrimPrefix(ls[0], kit.Path("")+ice.PS), ls[1])
|
||||
} else {
|
||||
m.Warn(true, "not founc", cmd.Name)
|
||||
}
|
||||
|
@ -188,9 +188,7 @@ func init() {
|
||||
return // 没有权限
|
||||
}
|
||||
fields := kit.Split(kit.Select(kit.Select(DIR_DEF_FIELDS, m.OptionFields()), kit.Join(kit.Slice(arg, 1))))
|
||||
if m.Option(DIR_ROOT) != "" {
|
||||
m.Logs(mdb.SELECT, DIR_ROOT, m.Option(DIR_ROOT), mdb.FIELD, kit.Join(fields, ","))
|
||||
}
|
||||
m.Logs(mdb.SELECT, DIR_ROOT, m.Option(DIR_ROOT), DIR_REG, m.Option(DIR_REG), mdb.FIELD, kit.Join(fields, ","))
|
||||
_dir_list(m, root, name, 0, m.Option(DIR_DEEP) == ice.TRUE, kit.Select(TYPE_BOTH, m.Option(DIR_TYPE)), kit.Regexp(m.Option(DIR_REG)), fields)
|
||||
m.SortTimeR(mdb.TIME)
|
||||
m.StatusTimeCount()
|
||||
|
@ -60,19 +60,16 @@ func _go_complete(m *ice.Message, arg ...string) {
|
||||
}
|
||||
}
|
||||
func _go_exec(m *ice.Message, arg ...string) {
|
||||
args := []string{ice.ICE_BIN}
|
||||
if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
||||
args = append(args, cmd)
|
||||
ctx.ProcessCommand(m, cmd, kit.Simple())
|
||||
return
|
||||
}
|
||||
if m.Cmdy(cli.SYSTEM, args); cli.IsSuccess(m) {
|
||||
m.Result(m.Append(cli.CMD_ERR), m.Append(cli.CMD_OUT))
|
||||
m.SetAppend()
|
||||
}
|
||||
m.StatusTime(ctx.ARGS, kit.Join(args, ice.SP))
|
||||
}
|
||||
func _go_show(m *ice.Message, arg ...string) {
|
||||
if key := ctx.GetFileCmd(path.Join(arg[2], arg[1])); key != "" {
|
||||
ctx.ProcessCommand(m, key, kit.Simple())
|
||||
TagsList(m, "gotags", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
||||
return
|
||||
if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
||||
ctx.ProcessCommand(m, cmd, kit.Simple())
|
||||
} else if p := strings.ReplaceAll(path.Join(arg[2], arg[1]), ".go", ".shy"); arg[1] != "main.go" && nfs.ExistsFile(m, p) {
|
||||
ctx.ProcessCommand(m, "web.wiki.word", kit.Simple(p))
|
||||
} else {
|
||||
|
@ -35,12 +35,49 @@ func _js_main_script(m *ice.Message, arg ...string) (res []string) {
|
||||
return
|
||||
}
|
||||
|
||||
func _js_parse(m *ice.Message, arg ...string) {
|
||||
|
||||
}
|
||||
func _js_show(m *ice.Message, arg ...string) {
|
||||
m.Display(path.Join("/require", path.Join(arg[2], arg[1])))
|
||||
key := ctx.GetFileCmd(kit.Replace(path.Join(arg[2], arg[1]), ".js", ".go"))
|
||||
ctx.ProcessCommand(m, kit.Select("can.code.inner._plugin", key), kit.Simple())
|
||||
kind := ""
|
||||
m.Cmd(nfs.CAT, path.Join(arg[2], arg[1]), func(text string, index int) {
|
||||
ls := kit.Split(text, "\t ", ":,()")
|
||||
if strings.HasPrefix(text, "Volcanos(") {
|
||||
if kind = ls[2]; strings.Contains(text, "_init: ") {
|
||||
m.Push("line", index+1)
|
||||
m.Push("kind", kind)
|
||||
m.Push("name", "_init")
|
||||
m.Push("type", "function")
|
||||
}
|
||||
return
|
||||
}
|
||||
indent := 0
|
||||
for _, c := range text {
|
||||
if c == '\t' {
|
||||
indent++
|
||||
} else if c == ' ' {
|
||||
indent++
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
if len(ls) > 2 && ls[1] == ":" {
|
||||
if indent > 1 {
|
||||
return
|
||||
}
|
||||
m.Push("line", index+1)
|
||||
m.Push("kind", kind)
|
||||
m.Push("name", ls[0])
|
||||
m.Push("type", ls[2])
|
||||
}
|
||||
})
|
||||
m.StatusTimeCount()
|
||||
}
|
||||
func _js_exec(m *ice.Message, arg ...string) {
|
||||
m.Display(path.Join("/require", path.Join(arg[2], arg[1])))
|
||||
key := ctx.GetFileCmd(kit.Replace(path.Join(arg[2], arg[1]), ".js", ".go"))
|
||||
ctx.ProcessCommand(m, kit.Select("can.code.inner._plugin", key), kit.Simple())
|
||||
return
|
||||
args := kit.Simple("node", "-e", kit.Join(_js_main_script(m, arg...), ice.NL))
|
||||
m.Cmdy(cli.SYSTEM, args).StatusTime(ctx.ARGS, kit.Join(append([]string{ice.ICE_BIN, m.PrefixKey(), m.ActionKey()}, arg...), ice.SP))
|
||||
}
|
||||
|
@ -47,7 +47,14 @@ func init() {
|
||||
case ctx.INDEX:
|
||||
m.Cmdy(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, ice.OptionFields(ctx.INDEX))
|
||||
default:
|
||||
m.Cmdy(COMPLETE, mdb.FOREACH, arg[1], m.Option(ctx.ACTION))
|
||||
m.Cmdy(COMPLETE, mdb.FOREACH, kit.Select("", arg, 1), m.Option(ctx.ACTION))
|
||||
m.Cmd(mdb.RENDER, kit.Ext(m.Option(nfs.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH), ice.Option{nfs.DIR_ROOT, ""}).Tables(func(value ice.Maps) {
|
||||
m.Push(nfs.PATH, kit.Format("line:%s:%s:%s", value[nfs.LINE], value["kind"], value[mdb.NAME]))
|
||||
})
|
||||
m.Option(nfs.DIR_REG, "")
|
||||
for _, p := range kit.Split(kit.Select(m.Option(nfs.PATH), m.Option("paths"))) {
|
||||
nfs.DirDeepAll(m, nfs.PWD, p, nil, nfs.PATH)
|
||||
}
|
||||
}
|
||||
}
|
||||
}},
|
||||
|
Loading…
x
Reference in New Issue
Block a user