From c25cd76e385fbbc677e2948bc7788485d54deb17 Mon Sep 17 00:00:00 2001 From: shaoying Date: Fri, 14 Jun 2019 21:36:16 +0800 Subject: [PATCH] add some --- src/contexts/cli/cli.go | 15 +++++++++++++++ src/contexts/ssh/ssh.go | 22 +++++++++++++++++----- usr/librarys/example.js | 5 ++++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/contexts/cli/cli.go b/src/contexts/cli/cli.go index ac0fa9c8..9df16d1d 100644 --- a/src/contexts/cli/cli.go +++ b/src/contexts/cli/cli.go @@ -5,6 +5,7 @@ import ( "contexts/ctx" "encoding/csv" "encoding/json" + "os/user" "path" "toolkit" @@ -168,6 +169,11 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", _, file := path.Split(name) 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) { if value := os.Getenv(key); value != "" { m.Conf("runtime", "boot."+key, kit.Select("", value, value != "-")) @@ -181,6 +187,15 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", } 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) { if len(arg) == 0 { m.Cmdy("ctx.config", "runtime") diff --git a/src/contexts/ssh/ssh.go b/src/contexts/ssh/ssh.go index b36239f3..efbca993 100644 --- a/src/contexts/ssh/ssh.go +++ b/src/contexts/ssh/ssh.go @@ -112,23 +112,35 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", "componet_tmpl": "componet", "componet_view": "Context", "componet_init": "", "componet_type": "private", "componet_ctx": "nfs", "componet_cmd": "dir", "componet_args": []interface{}{}, "inputs": []interface{}{ - map[string]interface{}{"type": "text", "name": "dir"}, - map[string]interface{}{"type": "button", "value": "执行"}, + map[string]interface{}{"type": "text", "name": "dir", "value": "work"}, + map[string]interface{}{"type": "button", "value": "查看"}, }, "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_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{}{ - "branch", "status", "diff", "log", "update", "commit", "push", + "branch", "status", "diff", "log", "update", "push", }}, 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", "componet_tmpl": "componet", "componet_view": "Context", "componet_init": "", "componet_type": "private", "componet_ctx": "web", "componet_cmd": "spide", diff --git a/usr/librarys/example.js b/usr/librarys/example.js index fce831ca..08e4cd3a 100644 --- a/usr/librarys/example.js +++ b/usr/librarys/example.js @@ -394,6 +394,9 @@ function Plugin(field, tool, args, plugin) { (option.ondaemon || function(msg) { 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) { + if (exports.length > 2) { + value = option[exports[2]].value + "/" + value + } page.Sync("plugin_"+exports[0]).set(value) }); (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 default: - args && count < args.length && (item.value = args[count++]) + args && count < args.length && (item.value = args[count++]||item.value||"") item.className = "args" }