mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 09:34:05 +08:00
opt bash.grant
This commit is contained in:
parent
80eda9d0c8
commit
50f7e56449
@ -22,7 +22,7 @@ func _zone_select(m *ice.Message, prefix, chain, zone string, id string) {
|
||||
cb := m.Optionv(kit.Keycb(SELECT))
|
||||
m.Richs(prefix, chain, kit.Select(kit.MDB_FOREACH, zone), func(key string, val map[string]interface{}) {
|
||||
if val = kit.GetMeta(val); zone == "" {
|
||||
if m.Option(FIELDS) == DETAIL {
|
||||
if m.OptionFields() == DETAIL {
|
||||
m.Push(DETAIL, val)
|
||||
} else {
|
||||
m.Push(key, val, fields)
|
||||
|
@ -207,7 +207,9 @@ func init() {
|
||||
m.Cmdy(TRASH, m.Option(kit.MDB_PATH))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Info("dir_root: %v", m.Option(DIR_ROOT))
|
||||
if m.Option(DIR_ROOT) != "" {
|
||||
m.Info("dir_root: %v", m.Option(DIR_ROOT))
|
||||
}
|
||||
_dir_list(m, kit.Select("./", m.Option(DIR_ROOT)), kit.Select("./", arg, 0),
|
||||
0, m.Option(DIR_DEEP) == ice.TRUE, kit.Select(TYPE_BOTH, m.Option(DIR_TYPE)), kit.Regexp(m.Option(DIR_REG)),
|
||||
kit.Split(kit.Select(kit.Select("time,path,size,action", m.OptionFields()), kit.Join(kit.Slice(arg, 1)))))
|
||||
|
@ -31,7 +31,7 @@ import (
|
||||
type {{.Option "name"}} struct {
|
||||
ice.{{.Option "type"}}
|
||||
|
||||
list string {{.Option "tag"}}
|
||||
list string {{.Option "tags"}}
|
||||
}
|
||||
|
||||
func (h {{.Option "name"}}) List(m *ice.Message, arg ...string) {
|
||||
@ -163,7 +163,7 @@ func init() {
|
||||
case "Data":
|
||||
_defs(m, "list", m.Option(kit.MDB_NAME)+" path auto upload")
|
||||
}
|
||||
m.Option("tag", kit.Format("`name:\"%s\" help:\"%s\"`", m.Option("list"), m.Option("help")))
|
||||
m.Option("tags", kit.Format("`name:\"%s\" help:\"%s\"`", m.Option("list"), m.Option("help")))
|
||||
|
||||
if p := path.Join(ice.SRC, m.Option(kit.MDB_ZONE), kit.Keys(m.Option(kit.MDB_NAME), GO)); !kit.FileExists(p) {
|
||||
_autogen_module(m, p)
|
||||
|
@ -76,6 +76,12 @@ func init() {
|
||||
"throw",
|
||||
"catch",
|
||||
"finally",
|
||||
|
||||
"can",
|
||||
"sub",
|
||||
"msg",
|
||||
"res",
|
||||
"target",
|
||||
),
|
||||
FUNCTION, kit.Simple(
|
||||
"window",
|
||||
@ -101,10 +107,6 @@ func init() {
|
||||
"cb",
|
||||
"cbs",
|
||||
"shy",
|
||||
"can",
|
||||
"sub",
|
||||
"msg",
|
||||
"res",
|
||||
"pane",
|
||||
"plugin",
|
||||
),
|
||||
|
@ -37,11 +37,6 @@ func init() {
|
||||
AUTOGEN: {Name: "create main=src/main.go@key key zone type=Zone,Hash,Data name=hi list help", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(AUTOGEN, mdb.CREATE, arg)
|
||||
}},
|
||||
BINPACK: {Name: "binpack", Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(AUTOGEN, BINPACK)
|
||||
m.Cmd(nfs.COPY, ice.GO_MOD, path.Join(ice.SRC_RELEASE, ice.GO_MOD))
|
||||
m.ProcessInner()
|
||||
}},
|
||||
COMPILE: {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Cmdy(COMPILE, ice.SRC_MAIN_GO); cli.IsSuccess(m) {
|
||||
m.Cmd(COMPILE, ice.SRC_MAIN_GO, ice.BIN_ICE_BIN)
|
||||
@ -49,6 +44,11 @@ func init() {
|
||||
}
|
||||
m.ProcessInner()
|
||||
}},
|
||||
BINPACK: {Name: "binpack", Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(AUTOGEN, BINPACK)
|
||||
m.Cmd(nfs.COPY, ice.GO_MOD, path.Join(ice.SRC_RELEASE, ice.GO_MOD))
|
||||
m.ProcessInner()
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmdy(INNER, arg)
|
||||
}},
|
||||
|
@ -43,6 +43,12 @@ func init() {
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
ice.AddRender(ice.RENDER_SCRIPT, func(m *ice.Message, cmd string, args ...interface{}) string {
|
||||
arg := kit.Simple(args...)
|
||||
if m.IsCliUA() {
|
||||
if len(arg) > 1 {
|
||||
arg = arg[1:]
|
||||
}
|
||||
return strings.Join(arg, ice.NL)
|
||||
}
|
||||
if len(arg) == 1 && arg[0] != BREAK {
|
||||
arg = []string{SHELL, arg[0]}
|
||||
}
|
||||
|
@ -11,38 +11,35 @@ import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const RUN = "run"
|
||||
func _run_action(m *ice.Message, cmd *ice.Command, code string, arg ...string) {
|
||||
m.Set(ice.MSG_RESULT)
|
||||
m.Echo("#/bin/bash\n")
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
"/run/": {Name: "/run/", Help: "执行", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Search(arg[0], func(_ *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
|
||||
p := strings.ReplaceAll(kit.Select("/app/cat.sh", cmd.Meta["display"]), ".js", ".sh")
|
||||
if strings.HasPrefix(p, ice.PS+ice.REQUIRE) {
|
||||
m.Cmdy(web.SPIDE, ice.DEV, web.SPIDE_RAW, p)
|
||||
} else {
|
||||
m.Cmdy(nfs.CAT, path.Join(ice.USR_INTSHELL, p))
|
||||
}
|
||||
m.Debug(kit.Formats(cmd.Meta))
|
||||
if m.Result() == "" || m.Result(1) == ice.ErrNotFound {
|
||||
m.Set(ice.MSG_RESULT)
|
||||
m.Echo("#/bin/bash\n")
|
||||
list := []string{}
|
||||
args := []string{}
|
||||
kit.Fetch(cmd.Meta["_trans"], func(k string, v string) {
|
||||
list = append(list, k)
|
||||
args = append(args, kit.Format(` %s)`, k))
|
||||
kit.Fetch(cmd.Meta[k], func(index int, value map[string]interface{}) {
|
||||
args = append(args, kit.Format(` read -p "read %s: " v; url="$url/%s/$v" `, value[kit.MDB_NAME], value[kit.MDB_NAME]))
|
||||
})
|
||||
args = append(args, kit.Format(` ;;`))
|
||||
})
|
||||
list = append(list, "quit")
|
||||
m.Echo(`
|
||||
list := []string{}
|
||||
args := []string{}
|
||||
kit.Fetch(cmd.Meta["_trans"], func(k string, v string) {
|
||||
list = append(list, k)
|
||||
args = append(args, kit.Format(` %s)`, k))
|
||||
kit.Fetch(cmd.Meta[k], func(index int, value map[string]interface{}) {
|
||||
args = append(args, kit.Format(` read -p "input %s: " v; url="$url/%s/$v" `, value[kit.MDB_NAME], value[kit.MDB_NAME]))
|
||||
})
|
||||
args = append(args, kit.Format(` ;;`))
|
||||
})
|
||||
|
||||
m.Echo(`
|
||||
ish_sys_dev_run_source() {
|
||||
select action in %s; do
|
||||
local url="run/action/run/%s/action/$action"
|
||||
case $action in
|
||||
%s
|
||||
esac
|
||||
ish_sys_dev_source $url
|
||||
done
|
||||
}
|
||||
`, kit.Join(list, ice.SP), arg[0], kit.Join(args, ice.NL))
|
||||
m.Echo(`
|
||||
ish_sys_dev_run_action() {
|
||||
select action in %s; do
|
||||
if [ "$action" = "quit" ]; then break; fi
|
||||
local url="run/action/run/%s/action/$action"
|
||||
case $action in
|
||||
%s
|
||||
@ -52,9 +49,39 @@ ish_sys_dev_run_action() {
|
||||
done
|
||||
}
|
||||
`, kit.Join(list, ice.SP), arg[0], kit.Join(args, ice.NL))
|
||||
m.Echo("cat $1\n")
|
||||
m.Debug("what %v", m.Result())
|
||||
|
||||
m.Echo(ice.NL)
|
||||
m.Echo(`ish_sys_dev_run_command() {
|
||||
ish_sys_dev_run %s "$@"
|
||||
}
|
||||
`, arg[0])
|
||||
m.Echo(ice.NL)
|
||||
|
||||
if code == "" {
|
||||
m.Echo("cat $1")
|
||||
} else {
|
||||
m.Echo(code)
|
||||
}
|
||||
m.Echo(ice.NL)
|
||||
m.Debug(m.Result())
|
||||
}
|
||||
|
||||
const RUN = "run"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
"/run/": {Name: "/run/", Help: "执行", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Search(arg[0], func(_ *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
|
||||
if p := strings.ReplaceAll(kit.Select("/app/cat.sh", cmd.Meta["display"]), ".js", ".sh"); strings.HasPrefix(p, ice.PS+ice.REQUIRE) {
|
||||
m.Cmdy(web.SPIDE, ice.DEV, web.SPIDE_RAW, p)
|
||||
} else {
|
||||
m.Cmdy(nfs.CAT, path.Join(ice.USR_INTSHELL, p))
|
||||
}
|
||||
if m.Result() == "" || m.Result(1) == ice.ErrNotFound {
|
||||
m.Set(ice.MSG_RESULT)
|
||||
}
|
||||
_run_action(m, cmd, m.Result(), arg...)
|
||||
})
|
||||
}},
|
||||
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -65,10 +92,6 @@ ish_sys_dev_run_action() {
|
||||
m.Table()
|
||||
}
|
||||
}},
|
||||
}, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if m.Right(arg) {
|
||||
m.Cmdy(arg)
|
||||
}
|
||||
}}},
|
||||
})
|
||||
}, ctx.CmdAction())},
|
||||
}})
|
||||
}
|
||||
|
@ -47,6 +47,9 @@ func init() {
|
||||
m.Option(ice.MSG_USERNAME, msg.Append(GRANT))
|
||||
m.Option(ice.MSG_USERROLE, aaa.UserRole(m, msg.Append(GRANT)))
|
||||
m.Option(tcp.HOSTNAME, msg.Append(tcp.HOSTNAME))
|
||||
if arg[0] == "/run/" {
|
||||
return
|
||||
}
|
||||
m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg)
|
||||
}},
|
||||
"/qrcode": {Name: "/qrcode", Help: "二维码", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user