Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Index = &ice.Context{Name: "code", Help: "编程中心", Caches: map[string]*ice.Cache{}, Configs: map[string]*ice.Config{ "compile": {Name: "compile", Help: "编译", Value: kit.Data("path", "usr/publish")}, "publish": {Name: "publish", Help: "发布", Value: kit.Data("path", "usr/publish")}, "upgrade": {Name: "upgrade", Help: "升级", Value: kit.Dict(kit.MDB_HASH, kit.Dict( "system", kit.Dict(kit.MDB_LIST, kit.List( kit.MDB_INPUT, "bin", "file", "ice.bin", "path", "bin/ice.bin", kit.MDB_INPUT, "bin", "file", "ice.sh", "path", "bin/ice.sh", )), ))}, "login": {Name: "login", Help: "登录", Value: kit.Data()}, }, Commands: map[string]*ice.Command{ ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Load() }}, ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save("login") }}, "login": {Name: "login", Help: "登录", List: ice.ListLook("key"), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) > 0 && arg[0] == "action" { switch arg[1] { case "modify": m.Richs("login", nil, m.Option("key"), func(key string, value map[string]interface{}) { m.Log(ice.LOG_MODIFY, "%s %s %v->%s", key, arg[2], value[arg[2]], arg[3]) value[arg[2]] = arg[3] }) case "delete": m.Log(ice.LOG_DELETE, "%s %s", m.Option("key"), m.Conf("login", kit.Keys("hash", m.Option("key")))) m.Conf("login", kit.Keys("hash", m.Option("key")), "") } return } switch kit.Select("list", arg, 0) { case "init": if m.Option("sid") != "" && m.Confs("login", []string{"hash", m.Option("sid"), "status"}) { m.Conf("login", []string{"hash", m.Option("sid"), "status"}, "login") m.Log(ice.LOG_LOGIN, "sid: %s", m.Option("sid")) m.Echo(m.Option("sid")) return } you := m.Conf(ice.WEB_SHARE, kit.Keys("hash", m.Option("share"), "name")) h := m.Rich("login", nil, kit.Dict( "status", "login", "type", kit.Select("zsh", arg, 1), "you", you, "pwd", m.Option("pwd"), "pid", m.Option("pid"), "pane", m.Option("pane"), "hostname", m.Option("hostname"), "username", m.Option("username"), )) m.Log(ice.LOG_LOGIN, "sid: %s you: %s", h, you) m.Echo(h) case "list": m.Richs("login", nil, "*", func(key string, value map[string]interface{}) { m.Push(key, value, []string{"time", "key", "type", "status", "you"}) pwd := strings.Split(kit.Format(value["pwd"]), "/") if len(pwd) > 3 { m.Push("pwd", strings.Join(pwd[len(pwd)-3:len(pwd)], "/")) } else { m.Push("pwd", value["pwd"]) } m.Push(key, value, []string{"pid", "pane", "hostname", "username"}) }) case "check": m.Richs("login", nil, m.Option("sid"), func(key string, value map[string]interface{}) { }) case "prune": if len(arg) > 1 && arg[1] == "all" { m.Conf("login", "hash", "") break } list := []string{} m.Richs("login", nil, "*", func(key string, value map[string]interface{}) { if len(arg) > 1 && arg[1] == "all" || value["status"] == "logout" { list = append(list, key) } }) kit.Fetch(list, func(index int, value string) { m.Log(ice.LOG_DELETE, "%s: %s", value, m.Conf("login", kit.Keys("hash", value))) m.Conf("login", kit.Keys("hash", value), "") }) m.Echo("%d", len(list)) case "exit": m.Richs("login", nil, m.Option("sid"), func(key string, value map[string]interface{}) { m.Log(ice.LOG_LOGOUT, "sid: %s", m.Option("sid")) value["status"] = "logout" }) default: m.Richs("login", nil, arg[0], func(key string, value map[string]interface{}) { m.Push("detail", value) }) } }}, "compile": {Name: "compile [os [arch]]", Help: "编译", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) == 0 { m.Cmdy("nfs.dir", m.Conf("publish", "meta.path"), "time size path") return } main := kit.Select("src/main.go", arg, 2) arch := kit.Select(m.Conf(ice.CLI_RUNTIME, "host.GOARCH"), arg, 1) goos := kit.Select(m.Conf(ice.CLI_RUNTIME, "host.GOOS"), arg, 0) file := path.Join(m.Conf("compile", "meta.path"), kit.Keys("ice", goos, arch)) m.Optionv("cmd_env", "GOCACHE", os.Getenv("GOCACHE"), "HOME", os.Getenv("HOME"), "GOARCH", arch, "GOOS", goos, "CGO_ENABLED", "0") m.Cmd(ice.CLI_SYSTEM, "go", "build", "-o", file, main) m.Cmdy(ice.WEB_STORY, ice.STORY_CATCH, "bin", file) m.Log(ice.LOG_EXPORT, "%s: %s", main, file) }}, "publish": {Name: "publish", Help: "发布", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) == 0 { m.Cmdy("nfs.dir", m.Conf("publish", "meta.path"), "time size path") return } p := arg[0] if s, e := os.Stat(arg[0]); m.Assert(e) && s.IsDir() { p = path.Base(arg[0]) + ".tar.gz" m.Cmd(ice.CLI_SYSTEM, "tar", "-zcf", p, arg[0]) defer func() { os.Remove(p) }() arg[0] = p } target := path.Join(m.Conf("publish", "meta.path"), path.Base(arg[0])) os.Remove(target) os.MkdirAll(path.Dir(target), 0777) os.Link(arg[0], target) m.Cmdy(ice.WEB_STORY, ice.STORY_CATCH, "bin", p) m.Log(ice.LOG_EXPORT, "%s: %s", arg[0], target) }}, "upgrade": {Name: "upgrade", Help: "升级", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { exit := true m.Grows("upgrade", "hash.system", "", "", func(index int, value map[string]interface{}) { if value["file"] == "ice.bin" { value["file"] = kit.Keys("ice", m.Conf(ice.CLI_RUNTIME, "host.GOOS"), m.Conf(ice.CLI_RUNTIME, "host.GOARCH")) } h := m.Cmdx(ice.WEB_SPIDE, "dev", "cache", "GET", "/publish/"+kit.Format(value["file"])) if h == "" { exit = false return } m.Cmd(ice.WEB_STORY, "add", "bin", value["path"], h) m.Cmd(ice.WEB_STORY, ice.STORY_WATCH, h, value["path"]) os.Chmod(kit.Format(value["path"]), 777) }) if exit { m.Cmd("exit") } }}, }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.