diff --git a/base/cli/forever.go b/base/cli/forever.go index f6b8fb98..6f5df296 100644 --- a/base/cli/forever.go +++ b/base/cli/forever.go @@ -61,22 +61,19 @@ func init() { } for { - logs.Println("run %s", kit.Join(arg, ice.SP)) - if IsSuccess(m.Cmd(SYSTEM, arg)) { + if logs.Println("run %s", kit.Join(arg, ice.SP)); IsSuccess(m.Cmd(SYSTEM, arg)) { logs.Println(ice.EXIT) // 正常退出 break - } else { - if m.Config("log.save") == ice.TRUE { - back := kit.Format("var/log.%s", logs.Now().Format("20060102_150405")) - m.Cmd(SYSTEM, "cp", "-r", "var/log", back, ice.Maps{CMD_OUTPUT: ""}) - m.Cmd(SYSTEM, "cp", "bin/boot.log", path.Join(back, "boot.log"), ice.Maps{CMD_OUTPUT: ""}) - // if IsSuccess(m.Cmd(SYSTEM, "grep", "fatal error: concurrent map read and map write", "bin/boot.log", ice.Maps{CMD_OUTPUT: ""})) { - // m.Cmd(SYSTEM, "cp", "bin/boot.log", path.Join(back, "boot.log"), ice.Maps{CMD_OUTPUT: ""}) - // } - } - logs.Println() - m.Sleep("1s") } + if logs.Println(); m.Config("log.save") == ice.TRUE { + back := kit.Format("var/log.%s", logs.Now().Format("20060102_150405")) + m.Cmd(SYSTEM, "cp", "-r", "var/log", back, ice.Maps{CMD_OUTPUT: ""}) + m.Cmd(SYSTEM, "cp", "bin/boot.log", path.Join(back, "boot.log"), ice.Maps{CMD_OUTPUT: ""}) + // if IsSuccess(m.Cmd(SYSTEM, "grep", "fatal error: concurrent map read and map write", "bin/boot.log", ice.Maps{CMD_OUTPUT: ""})) { + // m.Cmd(SYSTEM, "cp", "bin/boot.log", path.Join(back, "boot.log"), ice.Maps{CMD_OUTPUT: ""}) + // } + } + m.Sleep("1s") } }}, }) diff --git a/base/nfs/grep.go b/base/nfs/grep.go index 2552dd48..5203b35d 100644 --- a/base/nfs/grep.go +++ b/base/nfs/grep.go @@ -6,9 +6,9 @@ const GREP = "grep" func init() { Index.MergeCommands(ice.Commands{ - GREP: {Name: "grep path word auto", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { - m.Option("cmd_dir", arg[0]) - m.Split(m.Cmdx("cli.system", GREP, "--exclude=.[a-z]*", "--exclude-dir=.[a-z]*", "-rni", arg[1], "."), "file:line:text", ":") + GREP: {Name: "grep word path auto", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { + m.Option("cmd_dir", arg[1]) + m.Split(m.Cmdx("cli.system", GREP, "--exclude=.[a-z]*", "--exclude-dir=.[a-z]*", "-rni", arg[0], ice.PT), "file:line:text", ice.DF) }}, }) } diff --git a/core/code/compile.go b/core/code/compile.go index 83020d83..cc8430e6 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -59,7 +59,7 @@ func init() { // 执行编译 web.PushStream(m) main, file, goos, arch := _compile_target(m, arg...) - m.Optionv(cli.CMD_ENV, kit.Simple(m.Configv(cli.ENV), m.Optionv(cli.CMD_ENV), cli.HOME, kit.Env(cli.HOME), cli.PATH, kit.Env(cli.PATH), cli.GOOS, goos, cli.GOARCH, arch)) + m.Optionv(cli.CMD_ENV, kit.Simple(cli.HOME, kit.Env(cli.HOME), cli.PATH, kit.Env(cli.PATH), m.Configv(cli.ENV), m.Optionv(cli.ENV), cli.GOOS, goos, cli.GOARCH, arch)) m.Cmd(cli.SYSTEM, GO, "get", "shylinux.com/x/ice") if msg := m.Cmd(cli.SYSTEM, GO, cli.BUILD, "-o", file, main, ice.SRC_VERSION_GO, ice.SRC_BINPACK_GO); !cli.IsSuccess(msg) { m.Copy(msg) diff --git a/core/code/inner.go b/core/code/inner.go index 1fcb0ffc..5309b771 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -70,13 +70,6 @@ func _inner_line(m *ice.Message, file, text string) (string, int) { return "", 0 } -const ( - COMMENT = "comment" - KEYWORD = "keyword" - CONSTANT = "constant" - DATATYPE = "datatype" - FUNCTION = "function" -) const ( SPLIT = lex.SPLIT SPACE = lex.SPACE @@ -84,6 +77,13 @@ const ( PREFIX = lex.PREFIX SUFFIX = lex.SUFFIX ) +const ( + COMMENT = "comment" + KEYWORD = "keyword" + CONSTANT = "constant" + DATATYPE = "datatype" + FUNCTION = "function" +) const ( PLUG = "plug" SHOW = "show" @@ -92,7 +92,7 @@ const ( const INNER = "inner" func init() { - Index.Merge(&ice.Context{Commands: ice.Commands{ + Index.MergeCommands(ice.Commands{ INNER: {Name: "inner path=src/@key file=main.go@key line=1 auto", Help: "源代码", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.PrefixKey()) @@ -115,7 +115,7 @@ func init() { mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _inner_exec(m, arg[0], arg[1], arg[2]) }}, nfs.GREP: {Name: "grep", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(nfs.GREP, m.Option(nfs.PATH), arg[0]).StatusTimeCount(mdb.INDEX, 0) + m.Cmdy(nfs.GREP, arg[0], m.Option(nfs.PATH)).StatusTimeCount(mdb.INDEX, 0) }}, nfs.TAGS: {Name: "tags", Help: "索引", Hand: func(m *ice.Message, arg ...string) { if _inner_tags(m, m.Option(nfs.PATH), arg[0]); m.Length() == 0 { @@ -155,7 +155,7 @@ func init() { m.Option("exts", m.Config("show.exts")) ctx.DisplayLocal(m, "") }}, - }}) + }) } func PlugAction() ice.Actions { return ice.Actions{ diff --git a/core/code/vimer.go b/core/code/vimer.go index b75c916f..092678b1 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -138,8 +138,9 @@ func init() { COMPILE: {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) { cmds := []string{COMPILE, ice.SRC_MAIN_GO, ice.BIN_ICE_BIN} if strings.HasSuffix(os.Args[0], "contexts.app/Contents/MacOS/contexts") { - m.Option(cli.CMD_ENV, nfs.PATH, kit.Path("usr/local/go/bin")) - cmds = []string{cli.SYSTEM, "make", "app"} + m.Option(cli.ENV, "CGO_ENABLED", "1", cli.HOME, kit.Env(cli.HOME), cli.PATH, kit.Path("usr/local/go/bin")+ice.DF+kit.Env(cli.PATH)) + cmds = []string{COMPILE, "src/webview.go", "usr/publish/contexts.app/Contents/MacOS/contexts"} + // cmds = []string{cli.SYSTEM, cli.MAKE, "app"} } if msg := m.Cmd(cmds); cli.IsSuccess(msg) { m.Cmd(UPGRADE, cli.RESTART) diff --git a/exec.go b/exec.go index 329f8bee..b729e92e 100644 --- a/exec.go +++ b/exec.go @@ -51,7 +51,7 @@ func (m *Message) Assert(expr Any) bool { m.Result(ErrWarn, expr) panic(expr) } -func (m *Message) Sleep(d string, arg ...Any) *Message { +func (m *Message) Sleep(d Any, arg ...Any) *Message { if time.Sleep(kit.Duration(d)); len(arg) > 0 { m.Cmdy(arg...) } diff --git a/misc/git/status.go b/misc/git/status.go index 4cbc7d84..9189b0c1 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -234,8 +234,8 @@ func init() { PULL: {Name: "pull", Help: "下载", Hand: func(m *ice.Message, arg ...string) { _status_each(m, PULL, cli.SYSTEM, GIT, PULL) }}, - MAKE: {Name: "make", Help: "编译", Hand: func(m *ice.Message, arg ...string) { - web.PushStream(m, cli.SYSTEM, MAKE) + code.COMPILE: {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) { + m.Cmdy(code.VIMER, code.COMPILE) }}, PUSH: {Name: "push", Help: "上传", Hand: func(m *ice.Message, arg ...string) { if m.Option(REPOS) == "" { @@ -322,8 +322,8 @@ func init() { return } if len(arg) == 0 { - web.ToastProcess(m) - m.Action(PULL, MAKE, PUSH, TAGS, PIE, code.PUBLISH) + web.ToastProcess(m, "status") + m.Action(PULL, code.COMPILE, PUSH, TAGS, PIE, code.PUBLISH) files, adds, dels, last := _status_list(m) m.Status("cost", m.FormatCost(), "repos", m.Length(), "files", files, "adds", adds, "dels", dels, "last", last.Format(ice.MOD_TIME)) web.Toast3s(m, kit.Format("files: %d, adds: %d, dels: %d", files, adds, dels), ice.CONTEXTS)