diff --git a/src/examples/code/code.go b/src/examples/code/code.go index 0635f9d4..2c4965c4 100644 --- a/src/examples/code/code.go +++ b/src/examples/code/code.go @@ -156,6 +156,9 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", "zsh": {Name: "zsh dir grep key [split reg fields] [filter reg fields] [order key method] [group keys method] [sort keys method]", Form: map[string]int{"split": 2, "filter": 2, "order": 2, "group": 2, "sort": 2, "limit": 2}, Help: "终端", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) { + if len(arg) == 0 { + arg = append(arg, "") + } p, arg := kit.Select(".", arg[0]), arg[1:] switch arg[0] { case "prune": diff --git a/src/plugin/zsh/index.css b/src/plugin/zsh/index.css new file mode 100644 index 00000000..40e95720 --- /dev/null +++ b/src/plugin/zsh/index.css @@ -0,0 +1,3 @@ +fieldset.item.zsh div.output { +} + diff --git a/src/plugin/zsh/index.go b/src/plugin/zsh/index.go new file mode 100644 index 00000000..c68fe906 --- /dev/null +++ b/src/plugin/zsh/index.go @@ -0,0 +1,36 @@ +package main + +import ( + "contexts/cli" + "contexts/ctx" + "toolkit" + + "fmt" + "os" +) + +var Index = &ctx.Context{Name: `zsh`, Help: `plugin`, + 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/zsh/index.js b/src/plugin/zsh/index.js new file mode 100644 index 00000000..981ece74 --- /dev/null +++ b/src/plugin/zsh/index.js @@ -0,0 +1,3 @@ +Script["zsh/index.js"] = function(field, option, output) {return { +}} + diff --git a/src/plugin/zsh/index.shy b/src/plugin/zsh/index.shy new file mode 100644 index 00000000..13f12d1e --- /dev/null +++ b/src/plugin/zsh/index.shy @@ -0,0 +1,11 @@ +kit terminal "终端" private "web.code.zsh" "" terminal \ + text "times sids status pid pane hostname" name fields \ + feature detail "prune" "复制" "下载" \ + button "查看" action auto + +kit history "命令" private "web.code.zsh" "" history \ + text "10" name limit view tiny \ + text "0" name offset view tiny \ + text "times sids cmd pwd" name fields \ + button "查看" action auto +