1
0
forked from x/icebergs
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/aaa"
"shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/lex"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits" 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) 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) { }, 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 return
} else if len(arg) == 0 { } else if len(arg) == 0 {
_river_list(m) _river_list(m)

View File

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

View File

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

View File

@ -47,25 +47,20 @@ func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
REPOS: {Name: "repos repos path auto create", Help: "代码库", Actions: ice.MergeActions(ice.Actions{ REPOS: {Name: "repos repos path auto create", Help: "代码库", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { 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]) }) 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.IsAlpine(m, GIT)
cli.IsCentos(m, GIT) cli.IsCentos(m, GIT)
cli.IsUbuntu(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) { mdb.CREATE: {Name: "create repos branch name path", 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.OptionDefault(mdb.NAME, strings.TrimSuffix(path.Base(m.Option(REPOS)), ".git"))
m.Option(nfs.PATH, kit.Select(path.Join(ice.USR, m.Option(mdb.NAME)), m.Option(nfs.PATH))) m.OptionDefault(nfs.PATH, path.Join(ice.USR, m.Option(mdb.NAME)))
m.Option(REPOS, kit.Select(m.Config(REPOS)+ice.PS+m.Option(mdb.NAME), m.Option(REPOS))) m.OptionDefault(REPOS, m.Config(REPOS)+m.Option(mdb.NAME))
_repos_insert(m, m.Option(mdb.NAME), m.Option(nfs.PATH)) _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() { if s, e := nfs.StatFile(m, path.Join(m.Option(nfs.PATH), ".git")); e == nil && s.IsDir() {
return return
} }
// 下载仓库
if s, e := nfs.StatFile(m, m.Option(nfs.PATH)); e == nil && s.IsDir() { if s, e := nfs.StatFile(m, m.Option(nfs.PATH)); e == nil && s.IsDir() {
m.Option(cli.CMD_DIR, m.Option(nfs.PATH)) m.Option(cli.CMD_DIR, m.Option(nfs.PATH))
_git_cmd(m, INIT) _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)) _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) { }, 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) {
m.Cmd("web.code.git.repos", mdb.CREATE, m.OptionSimple(nfs.REPOS), nfs.PATH, m.Option(nfs.PATH)) if len(arg) == 0 {
}},
}, 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.HashSelect(m, arg...).Sort(mdb.NAME).RenameAppend(mdb.NAME, REPOS) 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]))) m.Cmdy(nfs.DIR, kit.Select("", arg, 1), "time,line,path", kit.Dict(nfs.DIR_ROOT, _repos_path(arg[0])))
} }
}}, }},