1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 01:24:05 +08:00
This commit is contained in:
bergyu 2022-01-23 14:16:05 +08:00
parent f993fa4890
commit 25628004a4
4 changed files with 63 additions and 16 deletions

View File

@ -3,7 +3,6 @@ package cli
import (
"bytes"
"io"
"io/ioutil"
"os"
"os/exec"
"path"
@ -34,21 +33,23 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
for _, p := range strings.Split(env[i+1], ice.DF) {
if _, err := os.Stat(path.Join(p, arg[0])); err == nil {
cmd.Path = path.Join(p, arg[0])
m.Debug("what %v", cmd.Path)
break
}
}
}
}
// 定制目录
if buf, err := ioutil.ReadFile(ice.ETC_PATH); err == nil && len(buf) > 0 {
for _, p := range strings.Split(string(buf), ice.NL) {
if _, e := os.Stat(path.Join(p, arg[0])); e == nil {
cmd.Path = kit.Path(path.Join(p, arg[0]))
break
}
}
}
// // 定制目录
// if buf, err := ioutil.ReadFile(ice.ETC_PATH); err == nil && len(buf) > 0 {
// for _, p := range strings.Split(string(buf), ice.NL) {
// if _, e := os.Stat(path.Join(p, arg[0])); e == nil {
// cmd.Path = kit.Path(path.Join(p, arg[0]))
// m.Debug("what %v", cmd.Path)
// break
// }
// }
// }
m.Debug("cmd: %v", cmd.Path)
if len(cmd.Env) > 0 {

View File

@ -26,6 +26,7 @@ func _dream_list(m *ice.Message) *ice.Message {
m.Push(cli.STATUS, cli.STOP)
m.PushButton(cli.START)
}
m.Push(mdb.LINK, kit.MergePOD(m.Option(ice.MSG_USERWEB), value[mdb.NAME]))
})
}
func _dream_show(m *ice.Message, name string) {
@ -82,7 +83,7 @@ func _dream_show(m *ice.Message, name string) {
m.Optionv(cli.CMD_OUTPUT, path.Join(p, m.Config(kit.Keys(cli.ENV, cli.CTX_LOG))))
// 启动任务
m.Cmd(cli.DAEMON, "ice.bin", SPACE, tcp.DIAL, ice.DEV, ice.DEV, mdb.NAME, name, m.OptionSimple(RIVER))
m.Cmd(cli.DAEMON, "ice.bin", SPACE, tcp.DIAL, ice.DEV, ice.OPS, mdb.NAME, name, m.OptionSimple(RIVER))
defer m.Event(DREAM_CREATE, kit.SimpleKV("", m.Option(mdb.TYPE), name)...)
m.Sleep3s()
}
@ -101,12 +102,14 @@ func init() {
_dream_show(m, m.Option(mdb.NAME, kit.Select(path.Base(m.Option(nfs.REPOS)), m.Option(mdb.NAME))))
}},
DREAM_STOP: {Name: "dream.stop type name", Help: "停止", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(SPACE, mdb.REMOVE, m.OptionSimple(mdb.NAME))
m.Cmd(DREAM, cli.START, m.OptionSimple(mdb.NAME))
if m.Cmd(DREAM, m.Option(mdb.NAME)).Length() > 0 {
m.Cmdy(SPACE, mdb.REMOVE, m.OptionSimple(mdb.NAME))
m.Cmd(DREAM, cli.START, m.OptionSimple(mdb.NAME))
}
}},
cli.STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(SPACE, mdb.REMOVE, m.OptionSimple(mdb.NAME))
m.Cmdy(SPACE, m.Option(mdb.NAME), "exit", "0")
m.Cmdy(SPACE, mdb.REMOVE, m.OptionSimple(mdb.NAME))
}},
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
_dream_list(m).Cut("name,status,time")

View File

@ -72,6 +72,48 @@ func _go_exec(m *ice.Message, arg ...string) {
m.SetAppend()
}
func _go_show(m *ice.Message, arg ...string) {
if arg[1] == "main.go" {
const (
PACKAGE = "package"
IMPORT = "import"
)
block := ""
index := 0
push := func(repos string) {
index++
m.Push("index", index)
m.Push("repos", repos)
}
m.Cmd(nfs.CAT, path.Join(arg[2], arg[1]), func(line string) {
ls := kit.Split(line)
switch {
case strings.HasPrefix(line, IMPORT+" ("):
block = IMPORT
return
case strings.HasPrefix(line, ")"):
block = ""
return
case strings.HasPrefix(line, IMPORT):
if len(ls) == 2 {
push(ls[1])
} else if len(ls) == 3 {
push(ls[2])
}
return
}
switch block {
case IMPORT:
if len(ls) == 0 {
push("")
} else if len(ls) == 1 {
push(ls[0])
} else if len(ls) == 2 {
push(ls[1])
}
}
})
return
}
if key, ok := ice.Info.File[path.Join(arg[2], arg[1])]; ok && key != "" {
m.ProcessCommand(key, kit.Simple())
} else {

View File

@ -53,7 +53,7 @@ func init() {
}, Commands: map[string]*ice.Command{
SESSION: {Name: "session session window pane cmd auto", Help: "会话管理", Action: map[string]*ice.Action{
web.DREAM_CREATE: {Name: "dream.create type name", Help: "梦想", Hand: func(m *ice.Message, arg ...string) {
if kit.IndexOf(m.Cmd(m.PrefixKey()).Appendv(SESSION), m.Option(mdb.NAME)) == -1 {
if m.Cmd(m.PrefixKey(), m.Option(mdb.NAME)).Length() > 0 {
m.Cmd(m.PrefixKey(), mdb.CREATE)
}
}},
@ -90,7 +90,8 @@ func init() {
m.Cmdy(cli.SYSTEM, TMUX, "split-window", "-t", kit.Keys(name, "2"), "-h")
m.Cmd(cli.SYSTEM, TMUX, "send-keys", "-t", kit.Keys(name, "3"), "ish_miss_log", "Enter")
m.Cmd(cli.SYSTEM, TMUX, "send-keys", "-t", kit.Keys(name, "2"), "ish_miss_space", "Enter")
// m.Cmd(cli.SYSTEM, TMUX, "send-keys", "-t", kit.Keys(name, "2"), "ish_miss_space", "Enter")
m.Cmd(cli.SYSTEM, TMUX, "send-keys", "-t", kit.Keys(name, "2"), "ish_miss_space")
m.Cmd(cli.SYSTEM, TMUX, "send-keys", "-t", kit.Keys(name, "1"), "vi etc/miss.sh", "Enter")
m.Cmdy(cli.SYSTEM, TMUX, "link-window", "-s", name, "-t", "miss:")