forked from x/icebergs
opt some
This commit is contained in:
parent
1095aee85c
commit
4f28389ff6
@ -42,7 +42,6 @@ func Process(m *ice.Message, key string, args ice.Any, arg ...string) {
|
||||
func ProcessField(m *ice.Message, cmd string, args ice.Any, arg ...string) *ice.Message {
|
||||
if cmd = kit.Select(m.ActionKey(), cmd); !kit.HasPrefixList(arg, ice.RUN) {
|
||||
m.Cmdy(COMMAND, cmd).Push(ARGS, kit.Format(_process_args(m, args))).Options(ice.MSG_INDEX, m.PrefixKey()).ProcessField(ACTION, m.ActionKey(), ice.RUN)
|
||||
m.Debug("what %v", m.FormatMeta())
|
||||
} else {
|
||||
kit.If(aaa.Right(m, cmd, arg[1:]), func() { m.Cmdy(cmd, arg[1:]) })
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -568,10 +569,9 @@ func init() {
|
||||
}
|
||||
nfs.Open(m, path.Join(arg...), func(r io.Reader, p string) {
|
||||
s := NewStack(m, nil, p, p).parse(m, p, r)
|
||||
if m.StatusTime(mdb.LINK, s.value(m, "_link")); m.Option(ice.DEBUG) == ice.TRUE {
|
||||
m.Options("__index", kit.Format(s.value(m, "_index")))
|
||||
m.Cmdy(INFO, arg)
|
||||
}
|
||||
m.Options("__index", kit.Format(s.value(m, "_index"))).Cmdy(INFO, arg)
|
||||
m.StatusTime(mdb.LINK, s.value(m, "_link"))
|
||||
ctx.AddFileCmd(kit.Path(p), m.Option("__index"))
|
||||
})
|
||||
}},
|
||||
})
|
||||
|
@ -2,12 +2,13 @@ package yac
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"path"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
@ -296,10 +297,12 @@ func init() {
|
||||
last, list := ice.Index, kit.Split(key, nfs.PT)
|
||||
for i := 1; i < len(list); i++ {
|
||||
has := false
|
||||
m.Debug("what %v", list[:i])
|
||||
if ice.Pulse.Search(strings.Join(list[:i], nfs.PT)+nfs.PT, func(p *ice.Context, s *ice.Context) { has, last = true, s }); !has {
|
||||
last = last.Register(&ice.Context{Name: list[i-1], Caches: ice.Caches{ice.CTX_FOLLOW: &ice.Cache{Value: kit.Keys(list[i-1])}}}, &web.Frame{})
|
||||
last = last.Register(&ice.Context{Name: list[i-1], Caches: ice.Caches{ice.CTX_FOLLOW: &ice.Cache{Value: kit.Keys(list[:i])}}}, &web.Frame{})
|
||||
}
|
||||
if i == len(list)-1 {
|
||||
m.Debug("what %v", last.Cap(ice.CTX_FOLLOW))
|
||||
last.Merge(&ice.Context{Commands: ice.Commands{list[i]: command}, Configs: ice.Configs{list[i]: config}})
|
||||
}
|
||||
}
|
||||
@ -447,11 +450,13 @@ func (m Message) Call(cmd string, arg ...Any) Any {
|
||||
s := _parse_stack(m.Message)
|
||||
m.Table(func(val ice.Maps) { s.calls(m.Message, arg[0], "", nil, Dict{kit.Dict(val)}) })
|
||||
case "Display":
|
||||
if len(arg) > 0 {
|
||||
m.ProcessDisplay(arg...)
|
||||
} else {
|
||||
m.ProcessDisplay(kit.Format("%s?_t=%d", Trans(_parse_stack(m.Message).value(m.Message, "_script")), time.Now().Unix()))
|
||||
file := kit.Format(Trans(arg[0]))
|
||||
if file == "" {
|
||||
file = kit.Split(_parse_stack(m.Message).name, ice.DF)[0]
|
||||
} else if !strings.HasPrefix(file, nfs.PS) && !strings.HasPrefix(file, ice.HTTP) {
|
||||
file = path.Join(path.Dir(kit.Split(_parse_stack(m.Message).name, ice.DF)[0]), file)
|
||||
}
|
||||
m.Display(ctx.FileURI(file), arg[1:]...)
|
||||
case "DebugStack":
|
||||
list := []string{}
|
||||
s := _parse_stack(m.Message)
|
||||
|
@ -52,7 +52,9 @@ func _autogen_import(m *ice.Message, main string, ctx string, mod string) {
|
||||
}
|
||||
func _autogen_version(m *ice.Message) string {
|
||||
if mod := _autogen_mod(m, ice.GO_MOD); !nfs.Exists(m, ".git") {
|
||||
m.Cmd(REPOS, mdb.CREATE, nfs.ORIGIN, "https://"+mod, mdb.NAME, path.Base(mod), nfs.PATH, nfs.PWD)
|
||||
m.Cmd(REPOS, "init", nfs.ORIGIN, kit.Select(m.Option(ice.MSG_USERHOST), ice.Info.Make.Domain)+"/x/"+path.Base(mod), mdb.NAME, path.Base(mod), nfs.PATH, nfs.PWD)
|
||||
defer m.Cmd(REPOS, "add", kit.Dict(nfs.REPOS, path.Base(mod), nfs.FILE, nfs.SRC))
|
||||
defer m.Cmd(REPOS, "add", kit.Dict(nfs.REPOS, path.Base(mod), nfs.FILE, "go.mod"))
|
||||
}
|
||||
m.Cmd(nfs.DEFS, ".gitignore", nfs.Template(m, "gitignore"))
|
||||
m.Cmd(nfs.DEFS, ice.SRC_BINPACK_GO, nfs.Template(m, ice.SRC_BINPACK_GO))
|
||||
@ -82,7 +84,7 @@ func _autogen_git(m *ice.Message, arg ...string) ice.Map {
|
||||
)
|
||||
}
|
||||
func _autogen_mod(m *ice.Message, file string) (mod string) {
|
||||
host := web.UserWeb(m).Hostname()
|
||||
host := kit.ParseURL(kit.Select(m.Option(ice.MSG_USERHOST), ice.Info.Make.Domain)).Hostname()
|
||||
if host == "" {
|
||||
host = path.Base(kit.Path(""))
|
||||
} else {
|
||||
|
@ -117,6 +117,7 @@ func init() {
|
||||
ProcessXterm(m, cmds, text, arg[1])
|
||||
}},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(yac.STACK, kit.Simple(path.Join(arg[2], arg[1])))
|
||||
if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
||||
ctx.ProcessCommand(m, cmd, kit.Simple())
|
||||
return
|
||||
|
@ -11,12 +11,26 @@ import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _js_show(m *ice.Message, arg ...string) {
|
||||
if arg[2] == ice.USR_VOLCANOS {
|
||||
if strings.HasPrefix(arg[1], "plugin/local/") {
|
||||
ctx.ProcessCommand(m, kit.Select(ice.CAN_PLUGIN, "web."+strings.Replace(strings.TrimSuffix(strings.TrimPrefix(arg[1], "plugin/local/"), nfs.PT+JS), nfs.PS, nfs.PT, -1)), kit.Simple())
|
||||
}
|
||||
} else {
|
||||
ctx.DisplayBase(m, require(arg[2], arg[1]))
|
||||
ctx.ProcessCommand(m, kit.Select(ice.CAN_PLUGIN, ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO))), kit.Simple())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const JS = "js"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
JS: {Name: "js path auto", Help: "前端", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
_js_show(m, arg...)
|
||||
return
|
||||
if arg[1] == "main.js" {
|
||||
m.EchoIFrame(nfs.PS)
|
||||
return
|
||||
@ -24,14 +38,7 @@ func init() {
|
||||
ProcessXterm(m, "node", kit.Format(`require("./usr/volcanos/proto.js"), require("./usr/volcanos/publish/client/nodejs/proto.js"), Volcanos.meta._main("%s")`, path.Join(nfs.PS, arg[2], arg[1])))
|
||||
}},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[2] == ice.USR_VOLCANOS {
|
||||
if strings.HasPrefix(arg[1], "plugin/local/") {
|
||||
ctx.ProcessCommand(m, kit.Select(ice.CAN_PLUGIN, "web."+strings.Replace(strings.TrimSuffix(strings.TrimPrefix(arg[1], "plugin/local/"), nfs.PT+JS), nfs.PS, nfs.PT, -1)), kit.Simple())
|
||||
}
|
||||
} else {
|
||||
ctx.DisplayBase(m, require(arg[2], arg[1]))
|
||||
ctx.ProcessCommand(m, kit.Select(ice.CAN_PLUGIN, ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO))), kit.Simple())
|
||||
}
|
||||
_js_show(m, arg...)
|
||||
}},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(nfs.Template(m, "demo.js")) }},
|
||||
}, PlugAction())},
|
||||
|
@ -56,6 +56,9 @@ func _repos_open(m *ice.Message, p string) *git.Repository {
|
||||
}
|
||||
func _repos_each(m *ice.Message, title string, cb func(*git.Repository, ice.Maps) error) {
|
||||
msg := m.Cmd("")
|
||||
if msg.Length() == 0 {
|
||||
return
|
||||
}
|
||||
web.GoToast(m, kit.Select(m.CommandKey()+ice.SP+m.ActionKey(), title), func(toast func(string, int, int)) {
|
||||
list, count, total := []string{}, 0, msg.Length()
|
||||
msg.Table(func(value ice.Maps) {
|
||||
@ -157,7 +160,11 @@ func _repos_status(m *ice.Message, p string, repos *git.Repository) error {
|
||||
if kit.IsIn(kit.Ext(k), "swp", "swo") {
|
||||
continue
|
||||
}
|
||||
switch m.Push(REPOS, p).Push(STATUS, string(v.Worktree)+string(v.Staging)).Push(nfs.FILE, k); v.Worktree {
|
||||
if m.Push(REPOS, p).Push(STATUS, string(v.Worktree)+string(v.Staging)).Push(nfs.FILE, k); m.Option("mode") == "zone" {
|
||||
ls := nfs.SplitPath(m, kit.Path(_repos_path(m, p), k))
|
||||
m.Push(nfs.PATH, ls[0]).Push(mdb.TEXT, string(v.Worktree)+string(v.Staging)+ice.SP+ls[0]+ls[1])
|
||||
}
|
||||
switch v.Worktree {
|
||||
case git.Untracked:
|
||||
m.PushButton(ADD, nfs.TRASH)
|
||||
case git.Modified:
|
||||
@ -277,6 +284,7 @@ func _repos_vimer(m *ice.Message, _repos_path func(m *ice.Message, p string, arg
|
||||
}
|
||||
|
||||
const (
|
||||
INIT = "init"
|
||||
CLONE = "clone"
|
||||
PULL = "pull"
|
||||
PUSH = "push"
|
||||
@ -287,6 +295,7 @@ const (
|
||||
COMMIT = "commit"
|
||||
BRANCH = "branch"
|
||||
|
||||
REMOTE = "remote"
|
||||
ORIGIN = "origin"
|
||||
MASTER = "master"
|
||||
INDEX = "index"
|
||||
@ -325,6 +334,11 @@ func init() {
|
||||
m.PushSearch(mdb.TYPE, web.LINK, mdb.NAME, m.CommandKey(), mdb.TEXT, m.MergePodCmd("", "", log.DEBUG, ice.TRUE))
|
||||
}
|
||||
}},
|
||||
INIT: {Name: "clone origin* branch name path", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(nfs.DEFS, kit.Path(".git/config"), nfs.Template(m, "config", m.Option("origin")))
|
||||
git.PlainInit(m.Option(nfs.PATH), false)
|
||||
_repos_insert(m, kit.Path(""))
|
||||
}},
|
||||
CLONE: {Name: "clone origin* branch name path", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.OptionDefault(mdb.NAME, path.Base(m.Option(ORIGIN)))
|
||||
m.OptionDefault(nfs.PATH, path.Join(path.Join(nfs.USR, m.Option(mdb.NAME))))
|
||||
@ -384,7 +398,17 @@ func init() {
|
||||
STASH: {Hand: func(m *ice.Message, arg ...string) { _repos_cmd(m, kit.Select(m.Option(REPOS), arg, 0), STASH) }},
|
||||
COMMIT: {Name: "commit actions=add,opt,fix comment*=some", Hand: func(m *ice.Message, arg ...string) {
|
||||
if work, err := _repos_open(m, m.Option(REPOS)).Worktree(); !m.Warn(err) {
|
||||
_, err := work.Commit(m.Option("actions")+ice.SP+m.Option("comment"), &git.CommitOptions{All: true})
|
||||
opt := &git.CommitOptions{All: true}
|
||||
if cfg, err := config.LoadConfig(config.GlobalScope); err == nil {
|
||||
if cfg.Author.Email == "" || cfg.Author.Name == "" {
|
||||
opt.Author = &object.Signature{
|
||||
Name: m.Option(ice.MSG_USERNAME),
|
||||
Email: m.Option(ice.MSG_USERNAME) + "@163.com",
|
||||
When: time.Now(),
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err := work.Commit(m.Option("actions")+ice.SP+m.Option("comment"), opt)
|
||||
m.Warn(err)
|
||||
}
|
||||
}},
|
||||
@ -392,9 +416,20 @@ func init() {
|
||||
if repos := kit.Select(m.Option(REPOS), arg, 0); repos != "" {
|
||||
_repos_status(m, repos, _repos_open(m, repos))
|
||||
} else {
|
||||
last, remote := "", ""
|
||||
_repos_each(m, "", func(repos *git.Repository, value ice.Maps) error {
|
||||
if refer, err := repos.Head(); err == nil {
|
||||
if commit, err := repos.CommitObject(refer.Hash()); err == nil {
|
||||
_last := commit.Author.When.Format(ice.MOD_TIME)
|
||||
kit.If(_last > last, func() { last = _last })
|
||||
}
|
||||
}
|
||||
if _remote, err := repos.Remote(ORIGIN); err == nil {
|
||||
remote = kit.Select(remote, kit.Select("", _remote.Config().URLs, 0))
|
||||
}
|
||||
return _repos_status(m, value[REPOS], repos)
|
||||
})
|
||||
m.Sort("repos,status,file").Status(mdb.TIME, last, REMOTE, remote, kit.MDB_COUNT, kit.Split(m.FormatSize())[0], kit.MDB_COST, m.FormatCost())
|
||||
}
|
||||
}},
|
||||
TOTAL: {Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -138,7 +138,7 @@ func init() {
|
||||
kit.If(m.Option(nfs.TO), func() { _git_cmd(m, CONFIG, "--global", "url."+m.Option(nfs.TO)+".insteadof", m.Option(nfs.FROM)) })
|
||||
}},
|
||||
OAUTH: {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen(kit.MergeURL2(kit.Select(ice.Info.Make.Remote, _git_remote(m)), "/chat/cmd/web.code.git.token/gen/", tcp.HOST, web.UserHost(m)))
|
||||
m.ProcessOpen(kit.MergeURL2(kit.Select(ice.Info.Make.Domain, _git_remote(m)), "/chat/cmd/web.code.git.token/gen/", tcp.HOST, m.Option(ice.MSG_USERWEB)))
|
||||
}},
|
||||
TAG: {Name: "tag version", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(REPOS, m.ActionKey(), arg)
|
||||
@ -165,13 +165,15 @@ func init() {
|
||||
}, gdb.EventAction(web.DREAM_TABLES), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 && arg[0] == ctx.ACTION {
|
||||
m.Cmdy(REPOS, arg)
|
||||
} else if _configs_get(m, USER_EMAIL) == "" {
|
||||
m.Echo("please config user.email").Action(CONFIGS)
|
||||
} else if len(arg) == 0 {
|
||||
m.Cmdy(REPOS, STATUS).Action(PULL, PUSH, "oauth", "insteadof")
|
||||
return
|
||||
files, adds, dels, last := _status_list(m)
|
||||
m.StatusTimeCount("files", files, "adds", adds, "dels", dels, "last", last, nfs.ORIGIN, _git_remote(m))
|
||||
m.Action(PULL, PUSH, "insteadof", "oauth").Sort("repos,type,file")
|
||||
} else {
|
||||
m.Cmdy(REPOS, arg[0], MASTER, INDEX, "README.md")
|
||||
return
|
||||
_repos_cmd(m, arg[0], DIFF)
|
||||
files, adds, dels := _status_stat(m, 0, 0, 0)
|
||||
m.StatusTime("files", files, "adds", adds, "dels", dels)
|
||||
|
@ -34,6 +34,10 @@ func init() {
|
||||
cli.MAKE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessReplace(kit.MergeURL2(LOCAL, m.PrefixPath(SET), TOKEN, create(m)))
|
||||
}},
|
||||
GEN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessReplace(kit.MergeURL2(m.Option(tcp.HOST), m.PrefixPath(SET), TOKEN, create(m)))
|
||||
m.Debug("what %v", m.FormatMeta())
|
||||
}},
|
||||
web.PP(GEN): {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessReplace(kit.MergeURL2(m.Option(tcp.HOST), m.PrefixPath(SET), TOKEN, create(m)))
|
||||
}},
|
||||
|
@ -199,3 +199,9 @@ func (m *Message) EchoScript(arg ...string) *Message { return m.Echo(Render(m, R
|
||||
func (m *Message) EchoDownload(arg ...string) *Message {
|
||||
return m.Echo(Render(m, RENDER_DOWNLOAD, arg))
|
||||
}
|
||||
func (m *Message) Display(file string, arg ...Any) {
|
||||
if file == "" {
|
||||
file = kit.FileLine(2, 100)
|
||||
}
|
||||
m.Option(MSG_DISPLAY, kit.MergeURL(kit.Select(kit.ExtChange(file, JS), file, strings.Contains(file, QS)), arg...))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user