1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-26 01:04:06 +08:00
This commit is contained in:
shaoying 2019-06-14 21:36:16 +08:00
parent 6e40b977c0
commit c25cd76e38
3 changed files with 36 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import (
"contexts/ctx" "contexts/ctx"
"encoding/csv" "encoding/csv"
"encoding/json" "encoding/json"
"os/user"
"path" "path"
"toolkit" "toolkit"
@ -168,6 +169,11 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
_, file := path.Split(name) _, file := path.Split(name)
m.Conf("runtime", "boot.pathname", file) m.Conf("runtime", "boot.pathname", file)
} }
if user, e := user.Current(); e == nil {
ns := strings.Split(user.Username, "\\")
m.Conf("runtime", "boot.USER", ns[len(ns)-1])
m.Conf("runtime", "boot.username", ns[len(ns)-1])
}
m.Confm("runtime", "init_env", func(index int, key string) { m.Confm("runtime", "init_env", func(index int, key string) {
if value := os.Getenv(key); value != "" { if value := os.Getenv(key); value != "" {
m.Conf("runtime", "boot."+key, kit.Select("", value, value != "-")) m.Conf("runtime", "boot."+key, kit.Select("", value, value != "-"))
@ -181,6 +187,15 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
} }
return return
}}, }},
"publish": &ctx.Command{Name: "publish", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
if user, e := user.Current(); e == nil {
ns := strings.Split(user.Username, "\\")
m.Conf("runtime", "boot.username", ns[len(ns)-1])
m.Echo("%v--\n", ns)
m.Echo("%v--\n", ns[len(ns)-1])
}
return
}},
"runtime": &ctx.Command{Name: "runtime", Help: "runtime", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { "runtime": &ctx.Command{Name: "runtime", Help: "runtime", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
if len(arg) == 0 { if len(arg) == 0 {
m.Cmdy("ctx.config", "runtime") m.Cmdy("ctx.config", "runtime")

View File

@ -112,23 +112,35 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "nfs", "componet_cmd": "dir", "componet_type": "private", "componet_ctx": "nfs", "componet_cmd": "dir",
"componet_args": []interface{}{}, "inputs": []interface{}{ "componet_args": []interface{}{}, "inputs": []interface{}{
map[string]interface{}{"type": "text", "name": "dir"}, map[string]interface{}{"type": "text", "name": "dir", "value": "work"},
map[string]interface{}{"type": "button", "value": "执行"}, map[string]interface{}{"type": "button", "value": "查看"},
}, },
"display": map[string]interface{}{"hide_result": true}, "display": map[string]interface{}{"hide_result": true},
"exports": []interface{}{"dir", "filename"}, "exports": []interface{}{"dir", "filename", "dir"},
}, },
map[string]interface{}{"componet_name": "git", "componet_help": "git", map[string]interface{}{"componet_name": "status", "componet_help": "git",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "cli", "componet_cmd": "git", "componet_type": "private", "componet_ctx": "cli", "componet_cmd": "git",
"componet_args": []interface{}{}, "inputs": []interface{}{ "componet_args": []interface{}{}, "inputs": []interface{}{
map[string]interface{}{"type": "text", "name": "dir", "imports": "plugin_dir"}, map[string]interface{}{"type": "text", "name": "dir", "imports": "plugin_dir"},
map[string]interface{}{"type": "select", "name": "cmd", "values": []interface{}{ map[string]interface{}{"type": "select", "name": "cmd", "values": []interface{}{
"branch", "status", "diff", "log", "update", "commit", "push", "branch", "status", "diff", "log", "update", "push",
}}, }},
map[string]interface{}{"type": "button", "value": "执行"}, map[string]interface{}{"type": "button", "value": "执行"},
}, },
}, },
map[string]interface{}{"componet_name": "commit", "componet_help": "git",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "cli", "componet_cmd": "git",
"componet_args": []interface{}{}, "inputs": []interface{}{
map[string]interface{}{"type": "text", "name": "dir", "imports": "plugin_dir"},
map[string]interface{}{"type": "select", "name": "cmd", "values": []interface{}{
"commit",
}},
map[string]interface{}{"type": "text", "name": "commit"},
map[string]interface{}{"type": "button", "value": "执行"},
},
},
map[string]interface{}{"componet_name": "spide", "componet_help": "spide", map[string]interface{}{"componet_name": "spide", "componet_help": "spide",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "web", "componet_cmd": "spide", "componet_type": "private", "componet_ctx": "web", "componet_cmd": "spide",

View File

@ -394,6 +394,9 @@ function Plugin(field, tool, args, plugin) {
(option.ondaemon || function(msg) { (option.ondaemon || function(msg) {
output.innerHTML = "" output.innerHTML = ""
!display.hide_append && msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1], function(event, value) { !display.hide_append && msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1], function(event, value) {
if (exports.length > 2) {
value = option[exports[2]].value + "/" + value
}
page.Sync("plugin_"+exports[0]).set(value) page.Sync("plugin_"+exports[0]).set(value)
}); });
(display.show_result || !msg.append) && msg.result && kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}]) (display.show_result || !msg.append) && msg.result && kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}])
@ -487,7 +490,7 @@ function Plugin(field, tool, args, plugin) {
break break
default: default:
args && count < args.length && (item.value = args[count++]) args && count < args.length && (item.value = args[count++]||item.value||"")
item.className = "args" item.className = "args"
} }