1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-25 17:18:05 +08:00
This commit is contained in:
harveyshao 2022-12-03 23:14:16 +08:00
parent bfddbb18b6
commit d2027d19ea
5 changed files with 21 additions and 43 deletions

View File

@ -8,7 +8,6 @@ import (
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/lex"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"

View File

@ -56,7 +56,7 @@ func init() {
gdb.Event(m, RIVER_CREATE, RIVER, m.Option(ice.MSG_RIVER, h), arg)
}},
}, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,template"), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) {
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || if !aaa.Right(m, RIVER, arg) {
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || !aaa.Right(m, RIVER, arg) {
return
} else if len(arg) == 0 {
_river_list(m)

View File

@ -13,27 +13,18 @@ import (
)
func _defs_list(m *ice.Message) string {
list := []string{mdb.LIST}
switch m.Option(mdb.TYPE) {
case "Zone":
list = append(list, "zone id auto insert")
case "Hash":
list = append(list, "hash auto create")
case "Data":
list = append(list, "path auto")
case "Code":
list = append(list, "port path auto start order build download")
case "Lang":
list = append(list, "path auto")
}
return m.OptionDefault(mdb.LIST, kit.Join(list, ice.SP))
return m.OptionDefault(mdb.LIST, kit.Join([]string{mdb.LIST, ice.Maps{
"Zone": "zone id auto insert",
"Hash": "hash auto create",
"Data": "path auto",
"Lang": "path auto",
"Code": "port path auto start order build download",
}[m.Option(mdb.TYPE)]}, ice.SP))
}
func _autogen_source(m *ice.Message, main, file string) {
main = strings.ReplaceAll(main, ice.PT+GO, ice.PT+SHY)
m.Cmd(nfs.DEFS, main, `title "{{.Option "name"}}"
`)
m.Cmd(nfs.PUSH, main, ice.NL, "source "+strings.TrimPrefix(file, ice.SRC+ice.PS))
main = kit.ExtChange(main, SHY)
m.Cmd(nfs.DEFS, main, `title "{{.Option "name"}}"`+ice.NL)
m.Cmd(nfs.PUSH, main, ice.NL, ssh.SOURCE+ice.PS+strings.TrimPrefix(file, ice.SRC+ice.PS)+ice.NL)
}
func _autogen_script(m *ice.Message, dir string) {
m.Cmd(nfs.DEFS, dir, `chapter "{{.Option "name"}}"

View File

@ -8,12 +8,8 @@ import (
"shylinux.com/x/icebergs/core/code"
)
func _git_cmd(m *ice.Message, arg ...string) *ice.Message {
return m.Cmd(cli.SYSTEM, GIT, arg)
}
func _git_cmds(m *ice.Message, arg ...string) string {
return _git_cmd(m, arg...).Result()
}
func _git_cmd(m *ice.Message, arg ...string) *ice.Message { return m.Cmd(cli.SYSTEM, GIT, arg) }
func _git_cmds(m *ice.Message, arg ...string) string { return _git_cmd(m, arg...).Result() }
const GIT = "git"

View File

@ -47,25 +47,20 @@ func init() {
Index.MergeCommands(ice.Commands{
REPOS: {Name: "repos repos path auto create", Help: "代码库", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Conf(REPOS, mdb.HASH, "")
_repos_insert(m, path.Base(kit.Pwd()), kit.Pwd())
m.Cmd(nfs.DIR, ice.USR, "name,path", func(value ice.Maps) { _repos_insert(m, value[mdb.NAME], value[nfs.PATH]) })
_repos_insert(m, path.Base(kit.Pwd()), kit.Pwd())
cli.IsAlpine(m, GIT)
cli.IsCentos(m, GIT)
cli.IsUbuntu(m, GIT)
m.Config(REPOS, "https://shylinux.com/x")
}},
mdb.CREATE: {Name: "create repos branch name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
m.Option(mdb.NAME, kit.Select(strings.TrimSuffix(path.Base(m.Option(REPOS)), ".git"), m.Option(mdb.NAME)))
m.Option(nfs.PATH, kit.Select(path.Join(ice.USR, m.Option(mdb.NAME)), m.Option(nfs.PATH)))
m.Option(REPOS, kit.Select(m.Config(REPOS)+ice.PS+m.Option(mdb.NAME), m.Option(REPOS)))
mdb.CREATE: {Name: "create repos branch name path", Hand: func(m *ice.Message, arg ...string) {
m.OptionDefault(mdb.NAME, strings.TrimSuffix(path.Base(m.Option(REPOS)), ".git"))
m.OptionDefault(nfs.PATH, path.Join(ice.USR, m.Option(mdb.NAME)))
m.OptionDefault(REPOS, m.Config(REPOS)+m.Option(mdb.NAME))
_repos_insert(m, m.Option(mdb.NAME), m.Option(nfs.PATH))
if s, e := nfs.StatFile(m, path.Join(m.Option(nfs.PATH), ".git")); e == nil && s.IsDir() {
return
}
// 下载仓库
if s, e := nfs.StatFile(m, m.Option(nfs.PATH)); e == nil && s.IsDir() {
m.Option(cli.CMD_DIR, m.Option(nfs.PATH))
_git_cmd(m, INIT)
@ -76,13 +71,10 @@ func init() {
_git_cmd(m, CLONE, "-b", kit.Select(MASTER, m.Option(BRANCH)), m.Option(REPOS), m.Option(nfs.PATH))
}
}},
web.DREAM_OPEN: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd("web.code.git.repos", mdb.CREATE, m.OptionSimple(nfs.REPOS), nfs.PATH, m.Option(nfs.PATH))
}},
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,branch,commit,remote"), mdb.ClearHashOnExitAction()), Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 { // 仓库列表
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,branch,commit,remote", REPOS, "https://shylinux.com/x/"), mdb.ClearHashOnExitAction()), Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 {
mdb.HashSelect(m, arg...).Sort(mdb.NAME).RenameAppend(mdb.NAME, REPOS)
} else { // 文件列表
} else {
m.Cmdy(nfs.DIR, kit.Select("", arg, 1), "time,line,path", kit.Dict(nfs.DIR_ROOT, _repos_path(arg[0])))
}
}},