From c370d7b4aa2867b0fd69da2655e8f05ec454e54d Mon Sep 17 00:00:00 2001 From: shaoying Date: Mon, 16 Sep 2019 08:39:40 +0800 Subject: [PATCH] add love --- src/contexts/cli/version.go | 2 +- src/contexts/ssh/ssh.go | 18 ++++++++++++++++-- src/plugin/love/index.css | 2 ++ src/plugin/love/index.go | 36 ++++++++++++++++++++++++++++++++++++ src/plugin/love/index.js | 4 ++++ src/plugin/love/index.shy | 20 ++++++++++++++++++++ src/plugin/love/local.shy | 0 7 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 src/plugin/love/index.css create mode 100644 src/plugin/love/index.go create mode 100644 src/plugin/love/index.js create mode 100644 src/plugin/love/index.shy create mode 100644 src/plugin/love/local.shy diff --git a/src/contexts/cli/version.go b/src/contexts/cli/version.go index 6561c698..232822a3 100644 --- a/src/contexts/cli/version.go +++ b/src/contexts/cli/version.go @@ -4,5 +4,5 @@ var version = struct { host string self int }{ - "2019-09-12 22:20:19", "centos", 532, + "2019-09-14 18:51:31", "com.mac", 494, } diff --git a/src/contexts/ssh/ssh.go b/src/contexts/ssh/ssh.go index 008ea18e..a02c3fb5 100644 --- a/src/contexts/ssh/ssh.go +++ b/src/contexts/ssh/ssh.go @@ -3,6 +3,7 @@ package ssh import ( "bufio" "contexts/ctx" + "encoding/json" "fmt" "os/exec" "sort" @@ -530,9 +531,22 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", case "update": index := kit.Int(arg[2]) - 1 - for i := 3; i < len(arg) - 1; i += 2 { + for i := 3; i < len(arg)-1; i += 2 { m.Confv("flow", []string{m.Option("river"), "data", arg[1], "list", kit.Format(index), arg[i]}, arg[i+1]) } + case "import": + m.Cmd("nfs.import", arg[2:]).Table(func(maps map[string]string, lists []string, line int) { + data := map[string]interface{}{} + extra := map[string]interface{}{} + for k, v := range maps { + data[k] = v + } + json.Unmarshal(([]byte)(maps["extra"]), &data) + data["extra"] = extra + + m.Confv("flow", []string{m.Option("river"), "data", arg[1], "list", "-2"}, map[string]interface{}{}) + + }) } return }}, @@ -686,7 +700,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", if rest := kit.Select("", names, 1); names[0] != "" { // 数字签名 if !m.Options("remote_code") && arg[0] != "_check" { - for _, k := range []string{"river"}{ + for _, k := range []string{"river"} { m.Option(k, m.Option(k)) } diff --git a/src/plugin/love/index.css b/src/plugin/love/index.css new file mode 100644 index 00000000..e60a8f8f --- /dev/null +++ b/src/plugin/love/index.css @@ -0,0 +1,2 @@ +fieldset.item.demo div.output { +} diff --git a/src/plugin/love/index.go b/src/plugin/love/index.go new file mode 100644 index 00000000..a04146f2 --- /dev/null +++ b/src/plugin/love/index.go @@ -0,0 +1,36 @@ +package main + +import ( + "contexts/cli" + "contexts/ctx" + "toolkit" + + "fmt" + "os" +) + +var Index = &ctx.Context{Name: "test", Help: "测试工具", + Caches: map[string]*ctx.Cache{}, + Configs: map[string]*ctx.Config{ + "_index": &ctx.Config{Name: "index", Value: []interface{}{ + map[string]interface{}{"name": "demo", "help": "demo", + "tmpl": "componet", "view": "", "init": "", + "type": "public", "ctx": "demo", "cmd": "demo", + "args": []interface{}{}, "inputs": []interface{}{ + map[string]interface{}{"type": "text", "name": "pod", "value": "hello world"}, + map[string]interface{}{"type": "button", "value": "执行"}, + }, + }, + }}, + }, + Commands: map[string]*ctx.Command{ + "demo": {Name: "demo", Help: "demo", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { + m.Echo(kit.Select("hello world", arg, 0)) + return + }}, + }, +} + +func main() { + fmt.Print(cli.Index.Plugin(Index, os.Args[1:])) +} diff --git a/src/plugin/love/index.js b/src/plugin/love/index.js new file mode 100644 index 00000000..28ad8994 --- /dev/null +++ b/src/plugin/love/index.js @@ -0,0 +1,4 @@ +{init: function(run, field, option, output) { + kit.Log("hello world") + return {} +}} diff --git a/src/plugin/love/index.shy b/src/plugin/love/index.shy new file mode 100644 index 00000000..e4058fd2 --- /dev/null +++ b/src/plugin/love/index.shy @@ -0,0 +1,20 @@ +fun meet "第一眼" public \ + text "love" name table imports plugin_table \ + text "" name when \ + text "" name where \ + button "操作" + + if $2 == "" + copy ssh.data show _ + return + end + if $3 == "" + return "meet miss" + end + copy ssh.data insert _ when _ where __ +end + +kit imports "导入" "" "" private "ssh.data" "import" \ + text "love" name table \ + text "" name file \ + button "导入" diff --git a/src/plugin/love/local.shy b/src/plugin/love/local.shy new file mode 100644 index 00000000..e69de29b