1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00

add cli.project.template

This commit is contained in:
shaoying 2019-07-15 22:01:34 +08:00
parent 4a45c806b2
commit b9f2557f1d
6 changed files with 54 additions and 10 deletions

View File

@ -157,9 +157,46 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
"github.com/go-cas/cas",
}, "plugin": map[string]interface{}{
"path": "src/plugin", "list": []interface{}{
map[string]interface{}{"name": "index.go", "text": ""},
map[string]interface{}{"name": "index.js", "text": ""},
map[string]interface{}{"name": "local.shy", "text": ""},
map[string]interface{}{"name": "index.go", "text": `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{}{"componet_name": "demo", "componet_help": "demo",
"componet_tmpl": "componet", "componet_view": "componet", "componet_init": "",
"componet_type": "public", "componet_ctx": "demo", "componet_cmd": "demo",
"componet_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:]))
}
`}, map[string]interface{}{"name": "index.js", "text": `
{init: function(page, pane, field, option, output) {
kit.Log("hello world")
}}
`}, map[string]interface{}{"name": "local.shy", "text": ` `},
},
}, "script": map[string]interface{}{
"path": "usr/script",
@ -779,6 +816,9 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
m.Confm("project", "plugin.list", func(index int, value map[string]interface{}) {
m.Cmd("nfs.copy", path.Join(q, kit.Format(value["name"])), path.Join(p, kit.Format(value["name"])))
})
for _, v := range arg[1:] {
m.Cmd("nfs.copy", path.Join(q, v), path.Join(p, v))
}
m.Cmdy("nfs.dir", q, "time", "size", "hash", "path")
return e
}
@ -838,7 +878,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
if s, e := p.Lookup("Index"); m.Assert(e) {
msg := m.Spawn(c.Register(*(s.(**ctx.Context)), nil, arg[0])).Cmd("_init", arg[1:])
msg.Cap("stream", arg[0])
msg.Confm("index", func(index int, value map[string]interface{}) {
msg.Confm("_index", func(index int, value map[string]interface{}) {
value["componet_ctx"] = "cli." + arg[0]
m.Conf("ssh.componet", []interface{}{arg[0], index}, value)
m.Add("append", "index", index)

View File

@ -4,5 +4,5 @@ var version = struct {
host string
self int
}{
"2019-07-15 14:19:05", "ZYB-20190522USI", 148,
"2019-07-15 20:46:47", "ZYB-20190522USI.ubuntu", 168,
}

View File

@ -35,6 +35,7 @@ func (c *Context) Plugin(s *Context, args []string) string {
c.Register(s, nil)
m := &Message{code: 0, time: time.Now(), source: s, target: s, Meta: map[string][]string{}}
m.Option("log.disable", true)
m.Option("cli.modal", "action")
if len(args) == 0 {
m.Echo("%s: %s\n\n", s.Name, s.Help)

View File

@ -503,7 +503,6 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
"tool": &ctx.Command{Name: "tool", Help: "用户", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
if len(arg) == 0 {
m.Confm("componet", func(key string, index int, value map[string]interface{}) {
m.Log("fuck", "what %v %v %v", m.Option("username"), m.Conf("runtime", "user.name"), m.Conf("runtime", "work.name"))
if kit.Format(value["componet_type"]) != "public" && m.Option("username") != m.Conf("runtime", "work.name") && m.Option("username") != m.Conf("runtime", "user.name") {
return
}
@ -558,7 +557,11 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
m.Add("append", "help", value["componet_help"])
m.Add("append", "view", value["componet_view"])
if kit.Right(value["componet_init"]) {
m.Add("append", "init", m.Cmdx("nfs.load", path.Join("usr/librarys/plugin", kit.Format(value["componet_init"])), -1))
script := m.Cmdx("nfs.load", path.Join(m.Conf("cli.publish", "path"), arg[0], kit.Format(value["componet_init"])), -1)
if script == "" {
script = m.Cmdx("nfs.load", path.Join("usr/librarys/plugin", kit.Format(value["componet_init"])), -1)
}
m.Add("append", "init", script)
} else {
m.Add("append", "init", "")
}
@ -1101,7 +1104,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
m.Option("bench", m.Cmdx("aaa.sess", "bench", "select"))
// 权限检查
if !m.Cmds("aaa.work", "right", "remote", arg[0]) {
if arg[0] != "tool" && !m.Cmds("aaa.work", "right", "remote", arg[0]) {
m.Echo("no right %s %s", "remote", arg[0])
return
}

View File

@ -63,7 +63,7 @@ var Index = &ctx.Context{Name: "sort", Help: "sort code",
"data": &ctx.Config{Name: "data", Value: map[string]interface{}{
"seed": []int{47, 59, 81, 40, 56, 0, 94, 11, 18, 25},
}},
"index": &ctx.Config{Name: "index", Value: []interface{}{
"_index": &ctx.Config{Name: "index", Value: []interface{}{
map[string]interface{}{"componet_name": "select", "componet_help": "选择排序",
"componet_tmpl": "componet", "componet_view": "componet", "componet_init": "",
"componet_type": "public", "componet_ctx": "sort", "componet_cmd": "select",

View File

@ -134,7 +134,7 @@ var Index = &ctx.Context{Name: "test", Help: "测试工具",
"prefix0": {Name: "prefix0", Help: "请求前缀", Value: "uri["},
"prefix1": {Name: "prefix1", Help: "参数前缀", Value: "request_param["},
"index": &ctx.Config{Name: "index", Value: []interface{}{
"_index": &ctx.Config{Name: "index", Value: []interface{}{
map[string]interface{}{"componet_name": "status", "componet_help": "状态",
"componet_tmpl": "componet", "componet_view": "Company", "componet_init": "",
"componet_type": "private", "componet_ctx": "test", "componet_cmd": "diff",