mirror of
https://shylinux.com/x/icebergs
synced 2025-06-26 02:17:30 +08:00
opt const
This commit is contained in:
parent
4f28389ff6
commit
7c2269d02d
@ -26,7 +26,7 @@ func init() {
|
||||
return
|
||||
}
|
||||
msg := m.Cmd("", m.Option(mdb.HASH))
|
||||
if ls := kit.Split(msg.Append(EMAIL), ice.AT); !m.Warn(msg.Length() == 0 || len(ls) < 2, ice.ErrNotValid, m.Option(mdb.HASH)) {
|
||||
if ls := kit.Split(msg.Append(EMAIL), mdb.AT); !m.Warn(msg.Length() == 0 || len(ls) < 2, ice.ErrNotValid, m.Option(mdb.HASH)) {
|
||||
m.Cmd(USER, mdb.CREATE, USERNICK, ls[0], USERNAME, msg.Append(EMAIL), USERZONE, ls[1])
|
||||
m.ProcessOpen(kit.MergeURL2(m.Option(ice.MSG_USERWEB), ice.PS, ice.MSG_SESSID, SessCreate(m, msg.Append(EMAIL)), mdb.HASH, ""))
|
||||
mdb.HashModify(m, m.OptionSimple(mdb.HASH), mdb.STATUS, ACCEPT)
|
||||
|
@ -24,7 +24,7 @@ func _totp_gen(per int64) string {
|
||||
func _totp_get(key string, per int64, num int) string {
|
||||
buf, now := []byte{}, kit.Int64(time.Now().Unix()/per)
|
||||
kit.For(8, func(i int) { buf = append(buf, byte((uint64(now) >> uint64(((7 - i) * 8))))) })
|
||||
kit.If(len(key)%8, func(l int) { key += strings.Repeat(ice.EQ, 8-l) })
|
||||
kit.If(len(key)%8, func(l int) { key += strings.Repeat(mdb.EQ, 8-l) })
|
||||
s, _ := base32.StdEncoding.DecodeString(strings.ToUpper(key))
|
||||
hm := hmac.New(sha1.New, s)
|
||||
hm.Write(buf)
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -24,7 +25,7 @@ func _daemon_exec(m *ice.Message, cmd *exec.Cmd) {
|
||||
cmd.Stderr = w
|
||||
}
|
||||
h := mdb.HashCreate(m.Spawn(), STATUS, START,
|
||||
ice.CMD, kit.Join(cmd.Args, ice.SP), DIR, cmd.Dir, ENV, kit.Select("", cmd.Env),
|
||||
ice.CMD, kit.Join(cmd.Args, lex.SP), DIR, cmd.Dir, ENV, kit.Select("", cmd.Env),
|
||||
m.OptionSimple(CMD_INPUT, CMD_OUTPUT, CMD_ERRPUT, mdb.CACHE_CLEAR_ON_EXIT),
|
||||
)
|
||||
if e := cmd.Start(); m.Warn(e, ice.ErrNotStart, cmd.Args) {
|
||||
|
@ -6,6 +6,8 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
"shylinux.com/x/toolkits/logs"
|
||||
@ -19,7 +21,7 @@ func BinPath(arg ...string) string {
|
||||
}
|
||||
kit.For(arg, func(p string) {
|
||||
list = append(list, kit.Path(p, ice.BIN), kit.Path(p, ice.USR_PUBLISH), kit.Path(p, ice.USR_LOCAL_BIN), kit.Path(p, ice.USR_LOCAL_GO_BIN))
|
||||
kit.For(kit.Reverse(strings.Split(ice.Pulse.Cmdx(nfs.CAT, kit.Path(p, ice.ETC_PATH)), ice.NL)), func(l string) {
|
||||
kit.For(kit.Reverse(strings.Split(ice.Pulse.Cmdx(nfs.CAT, kit.Path(p, ice.ETC_PATH)), lex.NL)), func(l string) {
|
||||
kit.If(strings.TrimSpace(l) != "" && !strings.HasPrefix(strings.TrimSpace(l), "#"), func() { push(kit.Path(p, l)) })
|
||||
})
|
||||
})
|
||||
@ -36,7 +38,7 @@ func init() {
|
||||
env := []string{PATH, BinPath(""), HOME, kit.Select(kit.Path(""), os.Getenv(HOME))}
|
||||
kit.For(ENV_LIST, func(k string) { kit.If(kit.Env(k) != "", func() { env = append(env, k, kit.Env(k)) }) })
|
||||
kit.For(os.Environ(), func(v string) {
|
||||
if ls := kit.Split(v, ice.EQ, ice.EQ); kit.IndexOf(env, ls[0]) == -1 && len(ls) > 1 {
|
||||
if ls := kit.Split(v, mdb.EQ, mdb.EQ); kit.IndexOf(env, ls[0]) == -1 && len(ls) > 1 {
|
||||
env = append(env, ls[0], ls[1])
|
||||
}
|
||||
})
|
||||
@ -59,7 +61,7 @@ func init() {
|
||||
return
|
||||
}
|
||||
for {
|
||||
if logs.Println("run %s", kit.Join(arg, ice.SP)); IsSuccess(m.Cmd(SYSTEM, arg)) {
|
||||
if logs.Println("run %s", kit.Join(arg, lex.SP)); IsSuccess(m.Cmd(SYSTEM, arg)) {
|
||||
logs.Println(ice.EXIT)
|
||||
break
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -47,8 +48,8 @@ func release(m *ice.Message) string {
|
||||
}
|
||||
m.Option(nfs.CAT_CONTENT, _release)
|
||||
_release = m.Cmdx(nfs.CAT, "/etc/os-release", kit.Dict(ice.MSG_USERROLE, aaa.ROOT), func(text string, _ int) string {
|
||||
if ls := kit.Split(text, ice.EQ); len(ls) > 1 {
|
||||
kit.Switch(ls[0], []string{"ID", "ID_LIKE"}, func() { osid = strings.TrimSpace(ls[1] + ice.SP + osid) })
|
||||
if ls := kit.Split(text, mdb.EQ); len(ls) > 1 {
|
||||
kit.Switch(ls[0], []string{"ID", "ID_LIKE"}, func() { osid = strings.TrimSpace(ls[1] + lex.SP + osid) })
|
||||
}
|
||||
return text
|
||||
})
|
||||
@ -59,7 +60,7 @@ func insert(m *ice.Message, sys, cmd string, arg ...string) bool {
|
||||
return false
|
||||
}
|
||||
if len(arg) > 0 {
|
||||
m.GoSleep("300ms", mdb.INSERT, kit.Keys(CLI, MIRRORS), "", mdb.ZONE, arg[0], OSID, sys, CMD, cmd+ice.SP+kit.Select(arg[0], arg, 1))
|
||||
m.GoSleep("300ms", mdb.INSERT, kit.Keys(CLI, MIRRORS), "", mdb.ZONE, arg[0], OSID, sys, CMD, cmd+lex.SP+kit.Select(arg[0], arg, 1))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"encoding/base64"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
"shylinux.com/x/icebergs/misc/qrcode"
|
||||
@ -25,9 +26,9 @@ func _qrcode_cli(m *ice.Message, text string) {
|
||||
}
|
||||
m.Echo("\033[4%sm \033[0m", kit.Select(bg, fg, col))
|
||||
}
|
||||
m.Echo(ice.NL)
|
||||
m.Echo(lex.NL)
|
||||
}
|
||||
m.Echo(text).Echo(ice.NL)
|
||||
m.Echo(text).Echo(lex.NL)
|
||||
}
|
||||
func _qrcode_web(m *ice.Message, text string) string {
|
||||
sc := qrcode.New(text)
|
||||
|
@ -52,17 +52,17 @@ func _runtime_init(m *ice.Message) {
|
||||
}
|
||||
func _runtime_hostinfo(m *ice.Message) {
|
||||
m.Push("nCPU", strings.Count(m.Cmdx(nfs.CAT, "/proc/cpuinfo"), "processor"))
|
||||
for i, ls := range strings.Split(m.Cmdx(nfs.CAT, "/proc/meminfo"), ice.NL) {
|
||||
for i, ls := range strings.Split(m.Cmdx(nfs.CAT, "/proc/meminfo"), lex.NL) {
|
||||
if vs := kit.Split(ls, ": "); len(vs) > 1 {
|
||||
if m.Push(strings.TrimSpace(vs[0]), kit.FmtSize(kit.Int64(strings.TrimSpace(vs[1]))*1024)); i > 1 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
m.Push("uptime", kit.Split(m.Cmdx(SYSTEM, "uptime"), ice.FS)[0])
|
||||
m.Push("uptime", kit.Split(m.Cmdx(SYSTEM, "uptime"), mdb.FS)[0])
|
||||
}
|
||||
func _runtime_diskinfo(m *ice.Message) {
|
||||
m.Spawn().Split(kit.Replace(m.Cmdx(SYSTEM, "df", "-h"), "Mounted on", "Mountedon"), "", ice.SP, ice.NL).Table(func(index int, value ice.Maps, head []string) {
|
||||
m.Spawn().Split(kit.Replace(m.Cmdx(SYSTEM, "df", "-h"), "Mounted on", "Mountedon"), "", lex.SP, lex.NL).Table(func(index int, value ice.Maps, head []string) {
|
||||
kit.If(strings.HasPrefix(value["Filesystem"], "/dev"), func() { m.Push("", value, head) })
|
||||
})
|
||||
m.RenameAppend("%iused", "piused", "Use%", "Usep")
|
||||
@ -181,7 +181,7 @@ func init() {
|
||||
}},
|
||||
ENV: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.For(os.Environ(), func(v string) {
|
||||
ls := strings.SplitN(v, ice.EQ, 2)
|
||||
ls := strings.SplitN(v, mdb.EQ, 2)
|
||||
m.Push(mdb.NAME, ls[0]).Push(mdb.VALUE, ls[1])
|
||||
})
|
||||
m.StatusTimeCount().Sort(mdb.NAME)
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -19,7 +20,7 @@ import (
|
||||
|
||||
func _path_split(ps string) []string {
|
||||
ps = kit.ReplaceAll(ps, "\\", nfs.PS)
|
||||
return kit.Split(ps, ice.NL+kit.Select(nfs.DF, ";", strings.Contains(ps, ";")), ice.NL)
|
||||
return kit.Split(ps, lex.NL+kit.Select(nfs.DF, ";", strings.Contains(ps, ";")), lex.NL)
|
||||
}
|
||||
func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
|
||||
bin, env := "", kit.Simple(m.Optionv(CMD_ENV))
|
||||
@ -32,7 +33,7 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
|
||||
})
|
||||
if bin == "" {
|
||||
if text := m.Cmdx(nfs.CAT, ice.ETC_PATH); len(text) > 0 {
|
||||
if bin = _system_find(m, arg[0], strings.Split(text, ice.NL)...); bin != "" {
|
||||
if bin = _system_find(m, arg[0], strings.Split(text, lex.NL)...); bin != "" {
|
||||
m.Logs(FIND, "etcpath cmd", bin)
|
||||
}
|
||||
}
|
||||
@ -89,11 +90,11 @@ func _system_exec(m *ice.Message, cmd *exec.Cmd) {
|
||||
cmd.Stdout, cmd.Stderr = out, err
|
||||
defer func() {
|
||||
m.Push(CMD_OUT, out.String()).Push(CMD_ERR, err.String())
|
||||
// m.Echo(strings.TrimRight(out.String(), ice.NL))
|
||||
// m.Echo(strings.TrimRight(out.String(), lex.NL))
|
||||
m.Echo(out.String())
|
||||
if m.IsErr() {
|
||||
m.Option(ice.MSG_ARGS, kit.Simple(http.StatusBadRequest, cmd.Args, err.String()))
|
||||
m.Echo(strings.TrimRight(err.String(), ice.NL))
|
||||
m.Echo(strings.TrimRight(err.String(), lex.NL))
|
||||
m.Debug("%s %s", err, out)
|
||||
}
|
||||
}()
|
||||
@ -160,7 +161,7 @@ func init() {
|
||||
if arg[0] == mdb.FOREACH && arg[1] == "" {
|
||||
return
|
||||
list := map[string]bool{"Terminal.app": true, "Docker.app": true, "Google Chrome.app": true}
|
||||
for _, p := range strings.Split(m.Cmdx("", nfs.SH, "-c", `ps aux|grep /Applications/|grep -v Cache|grep -v Helper|grep -v Widget|grep -v Extension|grep -v Chrome|grep -v com.app|grep -v grep|grep -o "[^/]*.app"|sort|uniq`), ice.NL) {
|
||||
for _, p := range strings.Split(m.Cmdx("", nfs.SH, "-c", `ps aux|grep /Applications/|grep -v Cache|grep -v Helper|grep -v Widget|grep -v Extension|grep -v Chrome|grep -v com.app|grep -v grep|grep -o "[^/]*.app"|sort|uniq`), lex.NL) {
|
||||
list[p] = true
|
||||
}
|
||||
for p := range list {
|
||||
@ -177,7 +178,7 @@ func init() {
|
||||
nfs.PUSH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
for _, p := range arg {
|
||||
if !strings.Contains(m.Cmdx(nfs.CAT, ice.ETC_PATH), p) {
|
||||
m.Cmd(nfs.PUSH, ice.ETC_PATH, strings.TrimSpace(p)+ice.NL)
|
||||
m.Cmd(nfs.PUSH, ice.ETC_PATH, strings.TrimSpace(p)+lex.NL)
|
||||
}
|
||||
}
|
||||
m.Cmdy(nfs.CAT, ice.ETC_PATH)
|
||||
@ -206,12 +207,12 @@ func init() {
|
||||
|
||||
func SystemFind(m *ice.Message, bin string, dir ...string) string {
|
||||
if text := m.Cmdx(nfs.CAT, ice.ETC_PATH); len(text) > 0 {
|
||||
dir = append(dir, strings.Split(text, ice.NL)...)
|
||||
dir = append(dir, strings.Split(text, lex.NL)...)
|
||||
}
|
||||
return _system_find(m, bin, append(dir, _path_split(kit.Env(PATH))...)...)
|
||||
}
|
||||
func SystemExec(m *ice.Message, arg ...string) string { return strings.TrimSpace(m.Cmdx(SYSTEM, arg)) }
|
||||
func SystemCmds(m *ice.Message, cmds string, args ...ice.Any) string {
|
||||
return strings.TrimRight(m.Cmdx(SYSTEM, "sh", "-c", kit.Format(cmds, args...), ice.Option{CMD_OUTPUT, ""}), ice.NL)
|
||||
return strings.TrimRight(m.Cmdx(SYSTEM, "sh", "-c", kit.Format(cmds, args...), ice.Option{CMD_OUTPUT, ""}), lex.NL)
|
||||
}
|
||||
func IsSuccess(m *ice.Message) bool { return m.Append(CODE) == "" || m.Append(CODE) == "0" }
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -69,7 +70,7 @@ func init() {
|
||||
}},
|
||||
mdb.EXPORT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
TravelCmd(m, func(key, file, line string) { m.Push(mdb.NAME, key).Push(nfs.FILE, file).Push(nfs.LINE, line) }).Sort(mdb.NAME).Table(func(value ice.Maps) {
|
||||
m.Echo(`%s %s %s;" f`+ice.NL, value[mdb.NAME], value[nfs.FILE], value[nfs.LINE])
|
||||
m.Echo(`%s %s %s;" f`+lex.NL, value[mdb.NAME], value[nfs.FILE], value[nfs.LINE])
|
||||
}).Cmd(nfs.SAVE, nfs.TAGS, m.Result())
|
||||
}},
|
||||
}, CmdAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -137,7 +138,7 @@ func FileURI(dir string) string {
|
||||
func FileCmd(dir string) string { return FileURI(kit.ExtChange(strings.Split(dir, nfs.DF)[0], nfs.GO)) }
|
||||
func AddFileCmd(dir, key string) {
|
||||
ice.Info.File[FileCmd(dir)] = key
|
||||
if ls := strings.SplitN(path.Join(kit.Slice(kit.Split(FileCmd(dir), nfs.PS), 1, 4)...), ice.AT, 2); len(ls) > 1 {
|
||||
if ls := strings.SplitN(path.Join(kit.Slice(kit.Split(FileCmd(dir), nfs.PS), 1, 4)...), mdb.AT, 2); len(ls) > 1 {
|
||||
ice.Info.Gomod[ls[0]] = ls[1]
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -19,47 +20,47 @@ func FormatPretty(v ice.Any, i, n int) string {
|
||||
if n == 0 {
|
||||
list := []string{"{"}
|
||||
kit.For(v, func(k string, v ice.Any) {
|
||||
list = append(list, kit.Format("%q", k), nfs.DF, FormatPretty(v, 0, 0), ice.FS)
|
||||
list = append(list, kit.Format("%q", k), nfs.DF, FormatPretty(v, 0, 0), mdb.FS)
|
||||
})
|
||||
list = list[:len(list)-1]
|
||||
list = append(list, "}")
|
||||
return strings.Join(list, "")
|
||||
}
|
||||
list := []string{"{", ice.NL}
|
||||
list := []string{"{", lex.NL}
|
||||
kit.For(v, func(k string, v ice.Any) {
|
||||
list = append(list, strings.Repeat(ice.TB, i+1), kit.Format("%q", k), nfs.DF)
|
||||
list = append(list, strings.Repeat(lex.TB, i+1), kit.Format("%q", k), nfs.DF)
|
||||
if i < n && !kit.IsIn(k, mdb.META) && !strings.HasPrefix(k, "_") {
|
||||
list = append(list, FormatPretty(v, i+1, n))
|
||||
} else {
|
||||
list = append(list, FormatPretty(v, 0, 0))
|
||||
}
|
||||
list = append(list, ice.FS, ice.NL)
|
||||
list = append(list, mdb.FS, lex.NL)
|
||||
})
|
||||
list = append(list[:len(list)-2], ice.NL)
|
||||
list = append(list, strings.Repeat(ice.TB, i), "}")
|
||||
list = append(list[:len(list)-2], lex.NL)
|
||||
list = append(list, strings.Repeat(lex.TB, i), "}")
|
||||
return strings.Join(list, "")
|
||||
case []ice.Any:
|
||||
if n == 0 {
|
||||
list := []string{"["}
|
||||
kit.For(v, func(k string, v ice.Any) {
|
||||
list = append(list, FormatPretty(v, 0, 0), ice.FS)
|
||||
list = append(list, FormatPretty(v, 0, 0), mdb.FS)
|
||||
})
|
||||
list = list[:len(list)-1]
|
||||
list = append(list, "]")
|
||||
return strings.Join(list, "")
|
||||
}
|
||||
list := []string{"[", ice.NL}
|
||||
list := []string{"[", lex.NL}
|
||||
kit.For(v, func(v ice.Any) {
|
||||
list = append(list, strings.Repeat(ice.TB, i+1))
|
||||
list = append(list, strings.Repeat(lex.TB, i+1))
|
||||
if i < n {
|
||||
list = append(list, FormatPretty(v, i+1, n))
|
||||
} else {
|
||||
list = append(list, FormatPretty(v, 0, 0))
|
||||
}
|
||||
list = append(list, ice.FS, ice.NL)
|
||||
list = append(list, mdb.FS, lex.NL)
|
||||
})
|
||||
list = append(list[:len(list)-2], ice.NL)
|
||||
list = append(list, strings.Repeat(ice.TB, i), "]")
|
||||
list = append(list[:len(list)-2], lex.NL)
|
||||
list = append(list, strings.Repeat(lex.TB, i), "]")
|
||||
return strings.Join(list, "")
|
||||
case string:
|
||||
return kit.Format(v)
|
||||
@ -69,21 +70,21 @@ func FormatPretty(v ice.Any, i, n int) string {
|
||||
}
|
||||
}
|
||||
func _config_format_list(m *ice.Message, v ice.Any) string {
|
||||
list := []string{"{", ice.NL}
|
||||
list := []string{"{", lex.NL}
|
||||
kit.For(v, func(k string, v ice.Any) {
|
||||
if k == mdb.HASH {
|
||||
list = append(list, ice.TB, kit.Format("%q", k), nfs.DF, "{", ice.NL)
|
||||
list = append(list, lex.TB, kit.Format("%q", k), nfs.DF, "{", lex.NL)
|
||||
kit.For(v, func(k string, v ice.Any) {
|
||||
list = append(list, ice.TB, ice.TB, kit.Format("%q", k), nfs.DF, kit.Format(v), ice.FS, ice.NL)
|
||||
list = append(list, lex.TB, lex.TB, kit.Format("%q", k), nfs.DF, kit.Format(v), mdb.FS, lex.NL)
|
||||
})
|
||||
list = list[:len(list)-2]
|
||||
list = append(list, ice.TB, ice.NL, ice.TB, "}", ice.FS, ice.NL)
|
||||
list = append(list, lex.TB, lex.NL, lex.TB, "}", mdb.FS, lex.NL)
|
||||
} else {
|
||||
list = append(list, ice.TB, kit.Format("%q", k), nfs.DF, kit.Format(v), ice.FS, ice.NL)
|
||||
list = append(list, lex.TB, kit.Format("%q", k), nfs.DF, kit.Format(v), mdb.FS, lex.NL)
|
||||
}
|
||||
})
|
||||
list = list[:len(list)-2]
|
||||
list = append(list, ice.NL, "}")
|
||||
list = append(list, lex.NL, "}")
|
||||
return strings.Join(list, "")
|
||||
}
|
||||
func _config_only(v ice.Any, arg ...string) bool {
|
||||
@ -139,7 +140,7 @@ func _config_load(m *ice.Message, name string, arg ...string) {
|
||||
func _config_make(m *ice.Message, key string, arg ...string) {
|
||||
msg := m.Spawn(m.Source())
|
||||
if len(arg) > 1 {
|
||||
kit.If(strings.HasPrefix(arg[1], ice.AT), func() { arg[1] = msg.Cmdx(nfs.CAT, arg[1][1:]) })
|
||||
kit.If(strings.HasPrefix(arg[1], mdb.AT), func() { arg[1] = msg.Cmdx(nfs.CAT, arg[1][1:]) })
|
||||
mdb.Confv(msg, key, arg[0], kit.Parse(nil, "", arg[1:]...))
|
||||
}
|
||||
if len(arg) > 0 {
|
||||
|
@ -47,7 +47,7 @@ func DisplayLocal(m displayMessage, file string, arg ...ice.Any) displayMessage
|
||||
return DisplayBase(m, file, arg...)
|
||||
}
|
||||
func DisplayBase(m displayMessage, file string, arg ...ice.Any) displayMessage {
|
||||
m.Option(ice.MSG_DISPLAY, kit.MergeURL(kit.Select(kit.ExtChange(file, nfs.JS), file, strings.Contains(file, ice.QS)), arg...))
|
||||
m.Option(ice.MSG_DISPLAY, kit.MergeURL(kit.Select(kit.ExtChange(file, nfs.JS), file, strings.Contains(file, mdb.QS)), arg...))
|
||||
return m
|
||||
}
|
||||
func Toolkit(m *ice.Message, arg ...string) {
|
||||
|
@ -85,6 +85,11 @@ func _split_list(m *ice.Message, file string, arg ...string) ice.Map {
|
||||
return list[0].(ice.Map)
|
||||
}
|
||||
|
||||
const (
|
||||
TB = ice.TB
|
||||
SP = ice.SP
|
||||
NL = ice.NL
|
||||
)
|
||||
const (
|
||||
SPLIT_SPACE = "split.space"
|
||||
SPLIT_BLOCK = "split.block"
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -31,16 +32,16 @@ func init() {
|
||||
if index < offset || index >= offset+limit || !strings.Contains(line, kit.Select("", arg, 3)) {
|
||||
return
|
||||
}
|
||||
ls := strings.SplitN(line, ice.SP, 6)
|
||||
ls := strings.SplitN(line, lex.SP, 6)
|
||||
if _, e := time.Parse(kit.Split(ice.MOD_TIMES)[0], ls[0]); e != nil || len(ls) < 6 {
|
||||
m.Push(mdb.TIME, "").Push(mdb.ID, "")
|
||||
m.Push(nfs.PATH, "").Push(nfs.FILE, "").Push(nfs.LINE, "")
|
||||
m.Push(ctx.SHIP, "").Push(ctx.ACTION, "").Push(nfs.CONTENT, line)
|
||||
return
|
||||
}
|
||||
m.Push(mdb.TIME, ls[0]+ice.SP+ls[1]).Push(mdb.ID, ls[2])
|
||||
m.Push(mdb.TIME, ls[0]+lex.SP+ls[1]).Push(mdb.ID, ls[2])
|
||||
m.Push(nfs.PATH, ice.USR_ICEBERGS)
|
||||
if i := strings.LastIndex(ls[5], ice.SP); strings.HasPrefix(ls[5][i+1:], ice.BASE) || strings.HasPrefix(ls[5][i+1:], ice.CORE) || strings.HasPrefix(ls[5][i+1:], ice.MISC) {
|
||||
if i := strings.LastIndex(ls[5], lex.SP); strings.HasPrefix(ls[5][i+1:], ice.BASE) || strings.HasPrefix(ls[5][i+1:], ice.CORE) || strings.HasPrefix(ls[5][i+1:], ice.MISC) {
|
||||
m.Push(nfs.FILE, strings.TrimSpace(strings.Split(ls[5][i:], nfs.DF)[0]))
|
||||
m.Push(nfs.LINE, strings.TrimSpace(strings.Split(ls[5][i:], nfs.DF)[1]))
|
||||
ls[5] = ls[5][:i]
|
||||
@ -52,10 +53,10 @@ func init() {
|
||||
m.Push(nfs.FILE, "base/web/serve.go").Push(nfs.LINE, "62")
|
||||
}
|
||||
if ls[4] == ice.LOG_CMDS {
|
||||
_ls := strings.SplitN(ls[5], ice.SP, 2)
|
||||
_ls := strings.SplitN(ls[5], lex.SP, 2)
|
||||
if ls[4], ls[5] = _ls[0], _ls[1]; !unicode.IsDigit(rune(ls[5][0])) {
|
||||
_ls := strings.SplitN(ls[5], ice.SP, 2)
|
||||
ls[4], ls[5] = ls[4]+ice.SP+_ls[0], _ls[1]
|
||||
_ls := strings.SplitN(ls[5], lex.SP, 2)
|
||||
ls[4], ls[5] = ls[4]+lex.SP+_ls[0], _ls[1]
|
||||
}
|
||||
}
|
||||
m.Push(ctx.SHIP, ls[3]).Push(ctx.ACTION, ls[4]).Push(nfs.CONTENT, ls[5])
|
||||
@ -66,9 +67,9 @@ func init() {
|
||||
if len(arg) > 2 && !strings.Contains(line, arg[2]) || index < offset {
|
||||
return
|
||||
}
|
||||
ls := strings.SplitN(line, ice.SP, 6)
|
||||
m.Push(mdb.TIME, ls[0]+ice.SP+ls[1]).Push(mdb.ID, ls[2])
|
||||
i := strings.LastIndex(ls[5], ice.SP)
|
||||
ls := strings.SplitN(line, lex.SP, 6)
|
||||
m.Push(mdb.TIME, ls[0]+lex.SP+ls[1]).Push(mdb.ID, ls[2])
|
||||
i := strings.LastIndex(ls[5], lex.SP)
|
||||
m.Push(nfs.PATH, ice.USR_ICEBERGS)
|
||||
m.Push(nfs.FILE, strings.TrimSpace(strings.Split(ls[5][i:], nfs.DF)[0]))
|
||||
m.Push(nfs.LINE, strings.TrimSpace(strings.Split(ls[5][i:], nfs.DF)[1]))
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"path"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -47,11 +48,11 @@ func (f *Frame) Start(m *ice.Message, arg ...string) {
|
||||
}
|
||||
defer bio.Flush()
|
||||
defer fmt.Fprintln(bio)
|
||||
fmt.Fprint(bio, l.p, ice.SP)
|
||||
fmt.Fprint(bio, l.p, lex.SP)
|
||||
view := mdb.Confm(m, VIEW, m.Conf(SHOW, kit.Keys(l.l, VIEW)))
|
||||
kit.If(ice.Info.Colors, func() { bio.WriteString(kit.Format(view[PREFIX])) })
|
||||
defer kit.If(ice.Info.Colors, func() { bio.WriteString(kit.Format(view[SUFFIX])) })
|
||||
fmt.Fprint(bio, l.l, ice.SP, l.s)
|
||||
fmt.Fprint(bio, l.l, lex.SP, l.s)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -18,8 +19,8 @@ func init() {
|
||||
stats := map[string]int{}
|
||||
m.Cmd(nfs.CAT, path.Join(ice.VAR_LOG, "watch.log"), func(text string) {
|
||||
ls := kit.Split(text)
|
||||
m.Push(mdb.TIME, ls[0]+ice.SP+ls[1]).Push(mdb.ID, ls[2]).Push(nfs.SOURCE, kit.Slice(ls, -1)[0])
|
||||
m.Push(ctx.SHIP, ls[3]).Push(ctx.ACTION, ls[4]).Push(nfs.CONTENT, kit.Join(kit.Slice(ls, 5, -1), ice.SP))
|
||||
m.Push(mdb.TIME, ls[0]+lex.SP+ls[1]).Push(mdb.ID, ls[2]).Push(nfs.SOURCE, kit.Slice(ls, -1)[0])
|
||||
m.Push(ctx.SHIP, ls[3]).Push(ctx.ACTION, ls[4]).Push(nfs.CONTENT, kit.Join(kit.Slice(ls, 5, -1), lex.SP))
|
||||
stats[ls[4]]++
|
||||
})
|
||||
m.StatusTimeCount(stats)
|
||||
|
@ -129,6 +129,11 @@ const (
|
||||
JSON = "json"
|
||||
CSV = "csv"
|
||||
SUB = "sub"
|
||||
|
||||
QS = ice.QS
|
||||
EQ = ice.EQ
|
||||
AT = ice.AT
|
||||
FS = ice.FS
|
||||
)
|
||||
|
||||
const MDB = "mdb"
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -20,8 +21,8 @@ func Render(msg *ice.Message, cmd string, arg ...ice.Any) (res string) {
|
||||
res = msg.TableEcho().Result()
|
||||
}
|
||||
}
|
||||
if fmt.Fprint(msg.O, res); !strings.HasSuffix(res, ice.NL) {
|
||||
fmt.Fprint(msg.O, ice.NL)
|
||||
if fmt.Fprint(msg.O, res); !strings.HasSuffix(res, lex.NL) {
|
||||
fmt.Fprint(msg.O, lex.NL)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"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/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -119,7 +120,7 @@ func (f *Frame) scan(m *ice.Message, h, line string) *Frame {
|
||||
continue
|
||||
}
|
||||
if line += bio.Text(); strings.Count(line, "`")%2 == 1 {
|
||||
line += ice.NL
|
||||
line += lex.NL
|
||||
ps = f.ps2
|
||||
continue
|
||||
}
|
||||
@ -223,8 +224,8 @@ func init() {
|
||||
}
|
||||
}},
|
||||
PROMPT: {Name: "prompt arg run", Help: "命令提示", Actions: ctx.ConfAction(
|
||||
PS1, ice.List{"\033[33;44m", mdb.COUNT, ice.AT, tcp.HOSTNAME, "[", mdb.TIME, "]", "\033[5m", TARGET, "\033[0m", "\033[44m", ">", "\033[0m ", "\033[?25h", "\033[32m"},
|
||||
PS2, ice.List{mdb.COUNT, ice.SP, TARGET, "> "},
|
||||
PS1, ice.List{"\033[33;44m", mdb.COUNT, mdb.AT, tcp.HOSTNAME, "[", mdb.TIME, "]", "\033[5m", TARGET, "\033[0m", "\033[44m", ">", "\033[0m ", "\033[?25h", "\033[32m"},
|
||||
PS2, ice.List{mdb.COUNT, lex.SP, TARGET, "> "},
|
||||
), Hand: func(m *ice.Message, arg ...string) {
|
||||
if f, ok := m.Target().Server().(*Frame); ok {
|
||||
f.prompt(m, arg...)
|
||||
@ -237,9 +238,9 @@ func init() {
|
||||
}},
|
||||
SCREEN: {Name: "screen run text", Help: "输出命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
if f, ok := m.Target().Server().(*Frame); ok {
|
||||
for _, line := range kit.Split(arg[0], ice.NL, ice.NL) {
|
||||
fmt.Fprintf(f.pipe, line+ice.NL)
|
||||
f.printf(m, line+ice.NL)
|
||||
for _, line := range kit.Split(arg[0], lex.NL, lex.NL) {
|
||||
fmt.Fprintf(f.pipe, line+lex.NL)
|
||||
f.printf(m, line+lex.NL)
|
||||
m.Sleep300ms()
|
||||
}
|
||||
m.Echo(f.res)
|
||||
@ -249,5 +250,5 @@ func init() {
|
||||
}
|
||||
|
||||
func PrintQRCode(m *ice.Message, url string) {
|
||||
m.Spawn(ice.OptionSilent()).Cmd(PRINTF, kit.Dict(nfs.CONTENT, ice.NL+ice.Render(m, ice.RENDER_QRCODE, url))).Cmd(PROMPT)
|
||||
m.Spawn(ice.OptionSilent()).Cmd(PRINTF, kit.Dict(nfs.CONTENT, lex.NL+ice.Render(m, ice.RENDER_QRCODE, url))).Cmd(PROMPT)
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -71,7 +72,7 @@ func _dream_template(m *ice.Message, p string) {
|
||||
switch m.Cmdy(nfs.COPY, path.Join(p, file), path.Join(ice.USR_LOCAL_WORK, m.Option(nfs.TEMPLATE), file)); file {
|
||||
case ice.GO_MOD:
|
||||
nfs.Rewrite(m, path.Join(p, file), func(line string) string {
|
||||
return kit.Select(line, nfs.MODULE+ice.SP+m.Option(mdb.NAME), strings.HasPrefix(line, nfs.MODULE))
|
||||
return kit.Select(line, nfs.MODULE+lex.SP+m.Option(mdb.NAME), strings.HasPrefix(line, nfs.MODULE))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
@ -43,7 +43,7 @@ func MergeURL2(m Message, url string, arg ...ice.Any) string {
|
||||
return kit.MergeURL2(m.Option(ice.MSG_USERWEB), url, arg...)
|
||||
}
|
||||
func MergeLink(m Message, url string, arg ...ice.Any) string {
|
||||
return kit.MergeURL(strings.Split(MergeURL2(m, url), ice.QS)[0], arg...)
|
||||
return kit.MergeURL(strings.Split(MergeURL2(m, url), mdb.QS)[0], arg...)
|
||||
}
|
||||
func ProcessPodCmd(m *ice.Message, pod, cmd string, arg ...ice.Any) {
|
||||
m.ProcessOpen(m.MergePodCmd(pod, cmd, arg...))
|
||||
|
@ -11,6 +11,7 @@ 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/nfs"
|
||||
"shylinux.com/x/icebergs/base/ssh"
|
||||
@ -77,7 +78,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response
|
||||
kit.For(kit.UnMarshal(r.Body), func(k string, v ice.Any) { m.Optionv(k, v) })
|
||||
default:
|
||||
r.ParseMultipartForm(kit.Int64(kit.Select("4096", r.Header.Get(ContentLength))))
|
||||
kit.For(r.PostForm, func(k string, v []string) { _log(FORM, k, kit.Join(v, ice.SP)).Optionv(k, v) })
|
||||
kit.For(r.PostForm, func(k string, v []string) { _log(FORM, k, kit.Join(v, lex.SP)).Optionv(k, v) })
|
||||
}
|
||||
kit.For(r.Cookies(), func(k, v string) { m.Optionv(k, v) })
|
||||
m.OptionDefault(ice.MSG_HEIGHT, "480", ice.MSG_WIDTH, "320")
|
||||
|
@ -136,6 +136,6 @@ func ShareLocalFile(m *ice.Message, arg ...string) {
|
||||
cache, size = s.ModTime(), s.Size()
|
||||
}
|
||||
kit.If(p == ice.BIN_ICE_BIN, func() { m.Option(ice.MSG_USERROLE, aaa.TECH) })
|
||||
m.Cmd(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, MergeLink(m, PP(SHARE, PROXY)), SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, ice.AT+p)
|
||||
m.Cmd(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, MergeLink(m, PP(SHARE, PROXY)), SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, mdb.AT+p)
|
||||
m.RenderDownload(kit.Select(p, pp, file.ExistsFile(pp)))
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/log"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
@ -42,7 +43,7 @@ func _space_dial(m *ice.Message, dev, name string, arg ...string) {
|
||||
}
|
||||
}).Cost(mdb.COUNT, i, mdb.NEXT, next, tcp.DIAL, dev, LINK, u.String()).Sleep(next)
|
||||
}
|
||||
}, kit.Join(kit.Simple(SPACE, name), ice.SP))
|
||||
}, kit.Join(kit.Simple(SPACE, name), lex.SP))
|
||||
}
|
||||
func _space_fork(m *ice.Message) {
|
||||
addr := kit.Select(m.R.RemoteAddr, m.R.Header.Get(ice.MSG_USERADDR))
|
||||
@ -60,7 +61,7 @@ func _space_fork(m *ice.Message) {
|
||||
gdb.Event(m, SPACE_LOGIN, args)
|
||||
}
|
||||
_space_handle(m, false, name, c)
|
||||
}, kit.Join(kit.Simple(SPACE, name), ice.SP))
|
||||
}, kit.Join(kit.Simple(SPACE, name), lex.SP))
|
||||
}
|
||||
}
|
||||
func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) {
|
||||
@ -80,7 +81,7 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) {
|
||||
msg.Option(ice.MSG_USERROLE, aaa.VOID)
|
||||
}
|
||||
if msg.Option("_exec") == "go" {
|
||||
m.Go(func() { _space_exec(msg, source, target, c) }, strings.Join(kit.Simple(SPACE, name, msg.Detailv()), ice.SP))
|
||||
m.Go(func() { _space_exec(msg, source, target, c) }, strings.Join(kit.Simple(SPACE, name, msg.Detailv()), lex.SP))
|
||||
} else {
|
||||
_space_exec(msg, source, target, c)
|
||||
}
|
||||
@ -128,7 +129,7 @@ func _space_send(m *ice.Message, name string, arg ...string) {
|
||||
wait, done := m.Wait(func(msg *ice.Message, arg ...string) {
|
||||
m.Cost(kit.Format("%v->[%v] %v %v", m.Optionv(ice.MSG_SOURCE), name, m.Detailv(), msg.FormatSize())).Copy(msg)
|
||||
})
|
||||
h := mdb.HashCreate(m.Spawn(), mdb.TYPE, tcp.SEND, mdb.NAME, kit.Keys(name, m.Target().ID()), mdb.TEXT, kit.Join(arg, ice.SP), kit.Dict(mdb.TARGET, done))
|
||||
h := mdb.HashCreate(m.Spawn(), mdb.TYPE, tcp.SEND, mdb.NAME, kit.Keys(name, m.Target().ID()), mdb.TEXT, kit.Join(arg, lex.SP), kit.Dict(mdb.TARGET, done))
|
||||
defer mdb.HashRemove(m, mdb.HASH, h)
|
||||
if target := kit.Split(name, nfs.PT, nfs.PT); mdb.HashSelectDetail(m, target[0], func(value ice.Map) {
|
||||
if c, ok := value[mdb.TARGET].(*websocket.Conn); !m.Warn(!ok, ice.ErrNotValid, mdb.TARGET) {
|
||||
|
@ -116,7 +116,7 @@ func _spide_part(m *ice.Message, arg ...string) (string, io.Reader) {
|
||||
if t, e := time.ParseInLocation(ice.MOD_TIME, arg[i+1], time.Local); !m.Warn(e, ice.ErrNotValid) {
|
||||
cache = t
|
||||
}
|
||||
} else if strings.HasPrefix(arg[i+1], ice.AT) {
|
||||
} else if strings.HasPrefix(arg[i+1], mdb.AT) {
|
||||
if s, e := nfs.StatFile(m, arg[i+1][1:]); !m.Warn(e, ice.ErrNotValid) {
|
||||
if s.Size() == size && s.ModTime().Before(cache) {
|
||||
continue
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -163,15 +164,15 @@ func (s *Stack) reads(m *ice.Message, cb func(k string) bool) {
|
||||
if s.skip++; s.skip < len(s.rest) {
|
||||
if k, v := s.rest[s.skip], kit.Select("", s.rest, s.skip+1); k == "`" {
|
||||
if len(block) > 0 {
|
||||
kit.If(s.line != last, func() { block, last = append(block, ice.NL), s.line })
|
||||
kit.If(s.line != last, func() { block, last = append(block, lex.NL), s.line })
|
||||
block = append(block, k)
|
||||
cb(strings.Join(block, ice.SP))
|
||||
cb(strings.Join(block, lex.SP))
|
||||
block = block[:0]
|
||||
} else {
|
||||
block = append(block, k)
|
||||
}
|
||||
} else if len(block) > 0 {
|
||||
kit.If(s.line != last, func() { block, last = append(block, ice.NL), s.line })
|
||||
kit.If(s.line != last, func() { block, last = append(block, lex.NL), s.line })
|
||||
block = append(block, k)
|
||||
} else if k == "*" && v == nfs.PS {
|
||||
comment = false
|
||||
@ -592,11 +593,11 @@ func StackHandler(m *ice.Message, arg ...string) {
|
||||
script = append(script, kit.Format("Volcanos(\"%s\", {", kit.TrimExt(path.Base(p), nfs.SHY)))
|
||||
kit.For(r, func(s string) {
|
||||
if strings.HasPrefix(s, FUNC) {
|
||||
script = append(script, ice.TB+strings.Replace(strings.TrimPrefix(s, FUNC+ice.SP), "(", ": function(", 1))
|
||||
script = append(script, lex.TB+strings.Replace(strings.TrimPrefix(s, FUNC+lex.SP), "(", ": function(", 1))
|
||||
} else if strings.HasPrefix(s, END) {
|
||||
script = append(script, ice.TB+"},")
|
||||
script = append(script, lex.TB+"},")
|
||||
} else {
|
||||
script = append(script, ice.TB+s)
|
||||
script = append(script, lex.TB+s)
|
||||
}
|
||||
})
|
||||
script = append(script, "})")
|
||||
@ -607,7 +608,7 @@ func StackHandler(m *ice.Message, arg ...string) {
|
||||
})
|
||||
if len(script) > 0 {
|
||||
p := ice.USR_SCRIPT + m.PrefixKey() + nfs.PS + "list.js"
|
||||
m.Cmd(nfs.SAVE, p, kit.Dict(nfs.CONTENT, strings.Join(script, ice.NL)))
|
||||
m.Cmd(nfs.SAVE, p, kit.Dict(nfs.CONTENT, strings.Join(script, lex.NL)))
|
||||
s.value(m, "_script", "/require/"+p)
|
||||
}
|
||||
cmd := m.Commands("")
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -58,7 +59,7 @@ func (s Field) Format() string {
|
||||
} else {
|
||||
res := []string{}
|
||||
kit.For(s.tags, func(k, v string) { res = append(res, kit.Format("%s:\"%s\"", k, v)) })
|
||||
return kit.Format("%s `%s`", types, strings.Join(res, ice.SP))
|
||||
return kit.Format("%s `%s`", types, strings.Join(res, lex.SP))
|
||||
}
|
||||
}
|
||||
func (s Function) Operate(op string, v Any) Any {
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
@ -439,7 +440,7 @@ func Format(arg ...Any) string {
|
||||
res = append(res, kit.Format(v))
|
||||
}
|
||||
}
|
||||
return strings.Join(res, ice.SP)
|
||||
return strings.Join(res, lex.SP)
|
||||
}
|
||||
|
||||
type Message struct{ *ice.Message }
|
||||
@ -452,9 +453,9 @@ func (m Message) Call(cmd string, arg ...Any) Any {
|
||||
case "Display":
|
||||
file := kit.Format(Trans(arg[0]))
|
||||
if file == "" {
|
||||
file = kit.Split(_parse_stack(m.Message).name, ice.DF)[0]
|
||||
file = kit.Split(_parse_stack(m.Message).name, nfs.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)
|
||||
file = path.Join(path.Dir(kit.Split(_parse_stack(m.Message).name, nfs.DF)[0]), file)
|
||||
}
|
||||
m.Display(ctx.FileURI(file), arg[1:]...)
|
||||
case "DebugStack":
|
||||
@ -465,7 +466,7 @@ func (m Message) Call(cmd string, arg ...Any) Any {
|
||||
kit.For(f.value, func(k string, v Any) { list = append(list, kit.Format("stack: %s %s:%#v", f.key, k, v)) })
|
||||
return false
|
||||
})
|
||||
m.Debug(ice.NL + strings.Join(list, ice.NL))
|
||||
m.Debug(lex.NL + strings.Join(list, lex.NL))
|
||||
default:
|
||||
msg, args := reflect.ValueOf(m), []reflect.Value{}
|
||||
kit.For(arg, func(v Any) { args = append(args, reflect.ValueOf(v)) })
|
||||
|
@ -23,9 +23,9 @@ func _cmd_file(m *ice.Message, arg ...string) bool {
|
||||
ctx.DisplayBase(m, ctx.FileURI(p))
|
||||
web.RenderCmd(m, kit.Select(ice.CAN_PLUGIN, ctx.GetFileCmd(p)))
|
||||
default:
|
||||
if p = strings.TrimPrefix(p, ice.SRC+ice.PS); nfs.Exists(m, path.Join(ice.SRC, p)) {
|
||||
if p = strings.TrimPrefix(p, ice.SRC+nfs.PS); nfs.Exists(m, path.Join(ice.SRC, p)) {
|
||||
if msg := m.Cmd(mdb.ENGINE, kit.Ext(p)); msg.Length() > 0 {
|
||||
m.Cmdy(mdb.ENGINE, kit.Ext(p), p, ice.SRC+ice.PS).RenderResult()
|
||||
m.Cmdy(mdb.ENGINE, kit.Ext(p), p, ice.SRC+nfs.PS).RenderResult()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,9 @@ import (
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
)
|
||||
@ -32,10 +34,10 @@ func init() {
|
||||
m.Option(ice.MSG_USERUA, msg.Append(ice.MSG_USERUA))
|
||||
}
|
||||
m.Cmd(web.SPACE, m.Option(web.SPACE), ice.MSG_SESSID, aaa.SessCreate(m, m.Option(ice.MSG_USERNAME)))
|
||||
m.ProcessLocation(web.MergeURL2(m, ice.PS))
|
||||
m.ProcessLocation(web.MergeURL2(m, nfs.PS))
|
||||
}},
|
||||
}, gdb.EventAction(web.SPACE_LOGIN), aaa.RoleAction(CONFIRM)), Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo("请授权: %s 访问设备: %s", arg[0], ice.Info.Hostname).Echo(ice.NL).EchoButton(CONFIRM)
|
||||
m.Echo("请授权: %s 访问设备: %s", arg[0], ice.Info.Hostname).Echo(lex.NL).EchoButton(CONFIRM)
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -86,7 +87,7 @@ func init() {
|
||||
msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME))
|
||||
kit.For([]string{aaa.USERNICK, aaa.LANGUAGE}, func(k string) { m.Option(k, msg.Append(k)) })
|
||||
for _, k := range []string{aaa.BACKGROUND, aaa.AVATAR} {
|
||||
if strings.HasPrefix(msg.Append(k), ice.PS) || strings.HasPrefix(msg.Append(k), ice.HTTP) {
|
||||
if strings.HasPrefix(msg.Append(k), nfs.PS) || strings.HasPrefix(msg.Append(k), ice.HTTP) {
|
||||
m.Option(k, msg.Append(k))
|
||||
} else if msg.Append(k) != "" && aaa.Right(m.Spawn(), msg.Append(k)) {
|
||||
m.Option(k, web.SHARE_LOCAL+k)
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -66,7 +67,7 @@ func init() {
|
||||
m.Echo(get(m, "place/v1/search", m.OptionSimple("keyword,boundary,page_index")))
|
||||
}},
|
||||
"direction": {Name: "direction", Help: "导航", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(get(m, "direction/v1/"+m.Option(mdb.TYPE)+ice.PS, m.OptionSimple("from,to")))
|
||||
m.Echo(get(m, "direction/v1/"+m.Option(mdb.TYPE)+nfs.PS, m.OptionSimple("from,to")))
|
||||
}},
|
||||
"district": {Name: "district", Help: "地区", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(get(m, "district/v1/getchildren", m.OptionSimple(mdb.ID)))
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/ssh"
|
||||
@ -20,15 +21,15 @@ import (
|
||||
func _merge_url(m *ice.Message, domain, key string, arg ...ice.Any) string {
|
||||
if domain == "" {
|
||||
if m.Option(ice.MSG_USERPOD) == "" {
|
||||
domain = web.MergeLink(m, ice.PS)
|
||||
domain = web.MergeLink(m, nfs.PS)
|
||||
} else {
|
||||
domain = web.MergeLink(m, "/chat/pod/"+m.Option(ice.MSG_USERPOD))
|
||||
}
|
||||
}
|
||||
if domain = strings.TrimSuffix(domain, ice.PS); strings.Contains(domain, "/chat/pod/") {
|
||||
if domain = strings.TrimSuffix(domain, nfs.PS); strings.Contains(domain, "/chat/pod/") {
|
||||
domain += web.P(strings.TrimPrefix(m.Prefix(web.P(key)), "web.chat."))
|
||||
} else {
|
||||
domain += path.Join(strings.TrimPrefix(strings.Replace(m.Target().Prefix(), ice.PT, ice.PS, -1), "web"), path.Join(key))
|
||||
domain += path.Join(strings.TrimPrefix(strings.Replace(m.Target().Prefix(), nfs.PT, nfs.PS, -1), "web"), path.Join(key))
|
||||
}
|
||||
return kit.MergeURL(domain, arg...)
|
||||
}
|
||||
@ -156,7 +157,7 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: ice.Comman
|
||||
}
|
||||
}},
|
||||
web.P(USERINFO): {Name: "/userinfo Authorization", Help: "信息", Hand: func(m *ice.Message, arg ...string) {
|
||||
if ls := strings.SplitN(m.R.Header.Get(web.Authorization), ice.SP, 2); m.Warn(len(ls) != 2 || ls[1] == "", ice.ErrNotFound, web.Bearer) {
|
||||
if ls := strings.SplitN(m.R.Header.Get(web.Authorization), lex.SP, 2); m.Warn(len(ls) != 2 || ls[1] == "", ice.ErrNotFound, web.Bearer) {
|
||||
m.RenderStatusBadRequest() // 参数错误
|
||||
|
||||
} else if msg := m.Cmd(ACCESS, ls[1]); msg.Append(mdb.TIME) < m.Time() {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
@ -31,6 +32,6 @@ func GetSSO(m *ice.Message) string {
|
||||
if !strings.Contains(link, web.PP(CHAT, POD)) {
|
||||
return ""
|
||||
}
|
||||
ls := strings.Split(kit.ParseURL(link).Path, ice.PS)
|
||||
ls := strings.Split(kit.ParseURL(link).Path, nfs.PS)
|
||||
return kit.MergeURL2(link, web.P(CHAT, SSO), web.SPACE, kit.Select("", ls, 3), cli.BACK, m.R.Header.Get(web.Referer))
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/ssh"
|
||||
@ -27,7 +28,7 @@ func _autogen_list(m *ice.Message) string {
|
||||
}
|
||||
func _autogen_source(m *ice.Message, main, file string) {
|
||||
m.Cmd(nfs.DEFS, main, nfs.Template(m, ice.SRC_MAIN_SHY))
|
||||
m.Cmd(nfs.PUSH, main, ssh.SOURCE+ice.SP+strings.TrimPrefix(file, ice.SRC+ice.PS)+ice.NL)
|
||||
m.Cmd(nfs.PUSH, main, ssh.SOURCE+lex.SP+strings.TrimPrefix(file, ice.SRC+nfs.PS)+lex.NL)
|
||||
}
|
||||
func _autogen_script(m *ice.Message, file string) { m.Cmd(nfs.DEFS, file, nfs.Template(m, "demo.shy")) }
|
||||
func _autogen_module(m *ice.Message, file string) { m.Cmd(nfs.DEFS, file, nfs.Template(m, "demo.go")) }
|
||||
@ -47,7 +48,7 @@ func _autogen_import(m *ice.Message, main string, ctx string, mod string) {
|
||||
done, list = true, append(list, kit.Format(`import _ "%s/src/%s"`, mod, ctx))
|
||||
}
|
||||
})
|
||||
m.Cmd(nfs.SAVE, main, kit.Join(list, ice.NL))
|
||||
m.Cmd(nfs.SAVE, main, kit.Join(list, lex.NL))
|
||||
m.Cmd(cli.SYSTEM, "goimports", "-w", main)
|
||||
}
|
||||
func _autogen_version(m *ice.Message) string {
|
||||
@ -70,7 +71,7 @@ func _autogen_gits(m *ice.Message, arg ...string) string {
|
||||
kit.For(_autogen_git(m, arg...), func(k, v string) {
|
||||
res = append(res, kit.Format(` %s: "%s",`, kit.Capital(k), strings.TrimSpace(v)))
|
||||
})
|
||||
return kit.Join(res, ice.NL)
|
||||
return kit.Join(res, lex.NL)
|
||||
}
|
||||
func _autogen_git(m *ice.Message, arg ...string) ice.Map {
|
||||
return kit.Dict(arg,
|
||||
@ -92,7 +93,7 @@ func _autogen_mod(m *ice.Message, file string) (mod string) {
|
||||
}
|
||||
m.Cmd(nfs.DEFS, file, nfs.Template(m, ice.GO_MOD, host))
|
||||
m.Cmd(nfs.CAT, file, func(line string) {
|
||||
kit.If(strings.HasPrefix(line, nfs.MODULE), func() { mod = kit.Split(line, ice.SP)[1] })
|
||||
kit.If(strings.HasPrefix(line, nfs.MODULE), func() { mod = kit.Split(line, lex.SP)[1] })
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"sync/atomic"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -18,7 +19,7 @@ func _bench_http(m *ice.Message, target string, arg ...string) {
|
||||
nconn := kit.Int64(kit.Select("10", m.Option(NCONN)))
|
||||
nreqs := kit.Int64(kit.Select("100", m.Option(NREQS)))
|
||||
list := []*http.Request{}
|
||||
for _, v := range strings.Split(target, ice.NL) {
|
||||
for _, v := range strings.Split(target, lex.NL) {
|
||||
switch ls := kit.Split(v); ls[0] {
|
||||
case http.MethodPost:
|
||||
if f, e := nfs.OpenFile(m, ls[2]); m.Assert(e) {
|
||||
|
@ -59,14 +59,14 @@ func _binpack_all(m *ice.Message) {
|
||||
list, cache := map[string]string{}, kit.Select(ice.USR_REQUIRE, m.Cmdx(cli.SYSTEM, GO, "env", "GOMODCACHE"))
|
||||
const _mod_ = "/pkg/mod/"
|
||||
for k := range ice.Info.File {
|
||||
switch ls := kit.Split(k, ice.PS); ls[1] {
|
||||
switch ls := kit.Split(k, nfs.PS); ls[1] {
|
||||
case ice.SRC:
|
||||
case ice.USR:
|
||||
list[path.Join(kit.Slice(ls, 1, -1)...)] = ""
|
||||
default:
|
||||
p := path.Join(cache, path.Join(kit.Slice(ls, 1, -1)...))
|
||||
_ls := strings.Split(strings.Split(p, _mod_)[1], ice.PS)
|
||||
list[path.Join(nfs.USR, strings.Split(_ls[2], ice.AT)[0], path.Join(kit.Slice(_ls, 3)...))] = p
|
||||
_ls := strings.Split(strings.Split(p, _mod_)[1], nfs.PS)
|
||||
list[path.Join(nfs.USR, strings.Split(_ls[2], mdb.AT)[0], path.Join(kit.Slice(_ls, 3)...))] = p
|
||||
}
|
||||
}
|
||||
for _, k := range kit.SortedKey(list) {
|
||||
@ -76,7 +76,7 @@ func _binpack_all(m *ice.Message) {
|
||||
})
|
||||
}
|
||||
mdb.HashSelects(m).Sort(nfs.PATH).Table(func(value ice.Maps) {
|
||||
if strings.HasSuffix(value[nfs.PATH], ice.PS) {
|
||||
if strings.HasSuffix(value[nfs.PATH], nfs.PS) {
|
||||
_binpack_dir(m, w, value[nfs.PATH])
|
||||
} else {
|
||||
_binpack_file(m, w, value[nfs.PATH])
|
||||
|
@ -55,7 +55,7 @@ func _css_show(m *ice.Message, arg ...string) {
|
||||
func _css_exec(m *ice.Message, arg ...string) {
|
||||
if arg[2] == ice.USR_VOLCANOS {
|
||||
if strings.HasPrefix(arg[1], ice.PLUGIN_LOCAL) {
|
||||
ctx.ProcessCommand(m, kit.Select(ice.CAN_PLUGIN, "web."+strings.Replace(kit.TrimExt(strings.TrimPrefix(arg[1], ice.PLUGIN_LOCAL), JS), ice.PS, ice.PT, -1)), kit.Simple())
|
||||
ctx.ProcessCommand(m, kit.Select(ice.CAN_PLUGIN, "web."+strings.Replace(kit.TrimExt(strings.TrimPrefix(arg[1], ice.PLUGIN_LOCAL), JS), nfs.PS, nfs.PT, -1)), kit.Simple())
|
||||
}
|
||||
} else {
|
||||
ctx.ProcessCommand(m, kit.Select(ice.CAN_PLUGIN, ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO))), kit.Simple())
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"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/nfs"
|
||||
"shylinux.com/x/icebergs/base/yac"
|
||||
@ -39,9 +40,9 @@ func _go_complete(m *ice.Message, arg ...string) {
|
||||
)
|
||||
if m.Option(mdb.TEXT) == "" {
|
||||
m.Push(mdb.TEXT, PACKAGE, IMPORT, CONST, TYPE, FUNC, VAR)
|
||||
} else if strings.HasSuffix(m.Option(mdb.TEXT), ice.PT) {
|
||||
} else if strings.HasSuffix(m.Option(mdb.TEXT), nfs.PT) {
|
||||
msg := m.Cmd(cli.SYSTEM, GO, "doc", _go_trans(m, kit.Slice(kit.Split(m.Option(mdb.TEXT), "\t ."), -1)[0]))
|
||||
for _, l := range strings.Split(kit.Select(msg.Result(), msg.Append(cli.CMD_OUT)), ice.NL) {
|
||||
for _, l := range strings.Split(kit.Select(msg.Result(), msg.Append(cli.CMD_OUT)), lex.NL) {
|
||||
if ls := kit.Split(l, "\t *", "()"); len(ls) > 1 {
|
||||
kit.Switch(ls[0], []string{CONST, TYPE, FUNC, VAR}, func() {
|
||||
kit.If(ls[1] == "(", func() { m.Push(mdb.NAME, ls[5]) }, func() { m.Push(mdb.NAME, ls[1]) })
|
||||
@ -51,8 +52,8 @@ func _go_complete(m *ice.Message, arg ...string) {
|
||||
}
|
||||
} else {
|
||||
m.Push(mdb.TEXT, "m", "msg", "code", "wiki", "chat", "team", "mall", "arg", "aaa", "cli", "ctx", "mdb", "nfs", "web", "ice", "kit")
|
||||
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, GO, "list", "std"), ice.NL) {
|
||||
m.Push(mdb.TEXT, kit.Slice(kit.Split(l, ice.PS), -1)[0])
|
||||
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, GO, "list", "std"), lex.NL) {
|
||||
m.Push(mdb.TEXT, kit.Slice(kit.Split(l, nfs.PS), -1)[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -109,8 +110,8 @@ func init() {
|
||||
return
|
||||
cmds, text := "ice.bin source stdio", ctx.GetFileCmd(path.Join(arg[2], arg[1]))
|
||||
if text != "" {
|
||||
ls := strings.Split(text, ice.PT)
|
||||
text = "~" + kit.Join(kit.Slice(ls, 0, -1), ice.PT) + ice.NL + kit.Slice(ls, -1)[0]
|
||||
ls := strings.Split(text, nfs.PT)
|
||||
text = "~" + kit.Join(kit.Slice(ls, 0, -1), nfs.PT) + lex.NL + kit.Slice(ls, -1)[0]
|
||||
} else {
|
||||
text = "cli.system go run " + path.Join(arg[2], arg[1])
|
||||
}
|
||||
@ -134,9 +135,9 @@ func init() {
|
||||
COMPLETE: {Hand: func(m *ice.Message, arg ...string) { _go_complete(m, arg...) }},
|
||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
for _, cmd := range []string{"guru", "gopls"} {
|
||||
if ls := kit.Split(m.Cmdx(cli.SYSTEM, cmd, "definition", m.Option(nfs.PATH)+m.Option(nfs.FILE)+ice.DF+"#"+m.Option("offset")), ice.DF); len(ls) > 0 {
|
||||
if ls := kit.Split(m.Cmdx(cli.SYSTEM, cmd, "definition", m.Option(nfs.PATH)+m.Option(nfs.FILE)+nfs.DF+"#"+m.Option("offset")), nfs.DF); len(ls) > 0 {
|
||||
if strings.HasPrefix(ls[0], kit.Path("")) {
|
||||
_ls := nfs.SplitPath(m, strings.TrimPrefix(ls[0], kit.Path("")+ice.PS))
|
||||
_ls := nfs.SplitPath(m, strings.TrimPrefix(ls[0], kit.Path("")+nfs.PS))
|
||||
m.Push(nfs.PATH, _ls[0]).Push(nfs.FILE, _ls[1]).Push(nfs.LINE, ls[1])
|
||||
return
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func require(arg ...string) string { return path.Join(ice.PS, ice.REQUIRE, path.Join(arg...)) }
|
||||
func require(arg ...string) string { return path.Join(nfs.PS, ice.REQUIRE, path.Join(arg...)) }
|
||||
|
||||
const HTML = "html"
|
||||
|
||||
|
@ -27,11 +27,11 @@ func _inner_exec(m *ice.Message, ext, file, dir string) {
|
||||
kit.If(aaa.Right(m, dir, file), func() { m.Cmdy(mdb.ENGINE, ext, file, dir) })
|
||||
}
|
||||
func _inner_tags(m *ice.Message, dir string, value string) {
|
||||
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, cli.GREP, "^"+value+"\\>", nfs.TAGS, dir), ice.NL) {
|
||||
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, cli.GREP, "^"+value+"\\>", nfs.TAGS, dir), lex.NL) {
|
||||
if strings.HasPrefix(l, "!_") {
|
||||
continue
|
||||
}
|
||||
ls := strings.SplitN(l, ice.TB, 3)
|
||||
ls := strings.SplitN(l, lex.TB, 3)
|
||||
if len(ls) < 3 {
|
||||
continue
|
||||
}
|
||||
@ -86,8 +86,8 @@ func init() {
|
||||
case ice.CMD:
|
||||
m.Cmd(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, ice.OptionFields(ctx.INDEX), func(value ice.Maps) {
|
||||
if strings.HasPrefix(value[ctx.INDEX], kit.Select("", arg, 1)) {
|
||||
ls := kit.Split(strings.TrimPrefix(value[ctx.INDEX], kit.Select("", arg, 1)), ice.PT)
|
||||
m.Push(arg[0], ls[0]+kit.Select("", ice.PT, len(ls) > 1))
|
||||
ls := kit.Split(strings.TrimPrefix(value[ctx.INDEX], kit.Select("", arg, 1)), nfs.PT)
|
||||
m.Push(arg[0], ls[0]+kit.Select("", nfs.PT, len(ls) > 1))
|
||||
}
|
||||
})
|
||||
case ctx.INDEX:
|
||||
@ -102,7 +102,7 @@ func init() {
|
||||
kit.If(strings.HasPrefix(p, bind[1]), func() { m.Cmdy(nfs.DIR, strings.Replace(p, bind[1], bind[0], 1), nfs.DIR_CLI_FIELDS) })
|
||||
case nfs.FILE:
|
||||
m.Option(nfs.DIR_DEEP, ice.TRUE)
|
||||
m.Cmdy(nfs.DIR, path.Join(m.Option(nfs.PATH), kit.Select(path.Dir(p), p, strings.HasSuffix(p, ice.PS))+ice.PS), nfs.PATH)
|
||||
m.Cmdy(nfs.DIR, path.Join(m.Option(nfs.PATH), kit.Select(path.Dir(p), p, strings.HasSuffix(p, nfs.PS))+nfs.PS), nfs.PATH)
|
||||
default:
|
||||
m.Cmdy(FAVOR, mdb.INPUTS, arg)
|
||||
}
|
||||
@ -116,14 +116,14 @@ func init() {
|
||||
m.Cmdy(NAVIGATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
|
||||
}},
|
||||
}, ctx.CmdAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[0] = strings.Split(arg[0], ice.FS)[0]; !strings.HasSuffix(arg[0], ice.PS) && len(arg) == 1 {
|
||||
arg[1] = kit.Slice(strings.Split(arg[0], ice.PS), -1)[0]
|
||||
if arg[0] = strings.Split(arg[0], mdb.FS)[0]; !strings.HasSuffix(arg[0], nfs.PS) && len(arg) == 1 {
|
||||
arg[1] = kit.Slice(strings.Split(arg[0], nfs.PS), -1)[0]
|
||||
arg[0] = strings.TrimSuffix(arg[0], arg[1])
|
||||
ctx.ProcessRewrite(m, nfs.PATH, arg[0], nfs.FILE, arg[1])
|
||||
} else if len(arg) < 2 {
|
||||
nfs.Dir(m, nfs.PATH)
|
||||
} else {
|
||||
arg[1] = strings.Split(arg[1], ice.FS)[0]
|
||||
arg[1] = strings.Split(arg[1], mdb.FS)[0]
|
||||
_inner_list(m, kit.Ext(arg[1]), arg[1], arg[0])
|
||||
ctx.DisplayLocal(m, "").Option(REPOS, kit.Join(m.Cmd(REPOS, ice.OptionFields(nfs.PATH)).Sort(nfs.PATH).Appendv(nfs.PATH)))
|
||||
}
|
||||
@ -157,11 +157,11 @@ func LoadPlug(m *ice.Message, lang ...string) {
|
||||
}
|
||||
}
|
||||
func TagsList(m *ice.Message, cmds ...string) {
|
||||
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, kit.Default(cmds, "ctags", "--excmd=number", "--sort=no", "-f", "-", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))), ice.NL) {
|
||||
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, kit.Default(cmds, "ctags", "--excmd=number", "--sort=no", "-f", "-", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))), lex.NL) {
|
||||
if strings.HasPrefix(l, "!_") {
|
||||
continue
|
||||
}
|
||||
ls := strings.Split(l, ice.TB)
|
||||
ls := strings.Split(l, lex.TB)
|
||||
if len(ls) < 3 {
|
||||
continue
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ func _install_path(m *ice.Message, link string) string {
|
||||
if p := path.Join(ice.USR_INSTALL, kit.TrimExt(u.Path)); nfs.Exists(m, p) {
|
||||
return p
|
||||
} else if pp := path.Join(ice.USR_INSTALL, path.Base(u.Path)); nfs.Exists(m, pp) {
|
||||
return path.Join(ice.USR_INSTALL, strings.Split(m.Cmd(nfs.TAR, pp, "", "1").Append(nfs.FILE), ice.PS)[0])
|
||||
return path.Join(ice.USR_INSTALL, strings.Split(m.Cmd(nfs.TAR, pp, "", "1").Append(nfs.FILE), nfs.PS)[0])
|
||||
} else {
|
||||
return p
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -44,13 +45,13 @@ func init() {
|
||||
}
|
||||
msg := m.Cmd(web.SPIDE, ice.DEV, web.SPIDE_CACHE, http.MethodGet, m.Option(SERVICE), m.OptionSimple(SECONDS))
|
||||
cmd := kit.Simple(mdb.Configv(m, PPROF), "-text", m.Option(BINNARY), msg.Append(nfs.FILE))
|
||||
m.Option(mdb.TEXT, strings.Join(kit.Slice(strings.Split(m.Cmdx(cli.SYSTEM, cmd), ice.NL), 0, 20), ice.NL))
|
||||
m.Option(mdb.TEXT, strings.Join(kit.Slice(strings.Split(m.Cmdx(cli.SYSTEM, cmd), lex.NL), 0, 20), lex.NL))
|
||||
mdb.ZoneInsert(m, m.OptionSimple("zone,text"), msg.AppendSimple(nfs.FILE))
|
||||
m.Echo(m.Option(mdb.TEXT)).ProcessInner()
|
||||
}},
|
||||
web.SERVE: {Help: "展示", Hand: func(m *ice.Message, arg ...string) {
|
||||
u := web.UserWeb(m)
|
||||
p := u.Hostname() + ice.DF + m.Cmdx(tcp.PORT, aaa.RIGHT)
|
||||
p := u.Hostname() + nfs.DF + m.Cmdx(tcp.PORT, aaa.RIGHT)
|
||||
m.Cmd(cli.DAEMON, mdb.Configv(m, PPROF), "-http="+p, m.Option(BINNARY), m.Option(nfs.FILE))
|
||||
m.Sleep3s().ProcessOpen(kit.Format("http://%s/ui/top", p))
|
||||
}},
|
||||
|
@ -10,6 +10,7 @@ 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/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
@ -19,8 +20,8 @@ import (
|
||||
func _publish_bin_list(m *ice.Message) *ice.Message {
|
||||
defer m.SortStrR(mdb.TIME)
|
||||
m.Option(cli.CMD_DIR, ice.USR_PUBLISH)
|
||||
for _, ls := range strings.Split(cli.SystemCmds(m, "ls |xargs file |grep executable"), ice.NL) {
|
||||
if file := strings.TrimSpace(strings.Split(ls, ice.DF)[0]); file != "" {
|
||||
for _, ls := range strings.Split(cli.SystemCmds(m, "ls |xargs file |grep executable"), lex.NL) {
|
||||
if file := strings.TrimSpace(strings.Split(ls, nfs.DF)[0]); file != "" {
|
||||
if s, e := nfs.StatFile(m, path.Join(ice.USR_PUBLISH, file)); e == nil {
|
||||
m.Push(mdb.TIME, s.ModTime()).Push(nfs.SIZE, kit.FmtSize(s.Size())).Push(nfs.PATH, file)
|
||||
m.PushDownload(mdb.LINK, file, path.Join(ice.USR_PUBLISH, file)).PushButton(nfs.TRASH)
|
||||
@ -46,7 +47,7 @@ func _publish_file(m *ice.Message, file string, arg ...string) string {
|
||||
func _publish_contexts(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.DIR_ROOT, "")
|
||||
for _, k := range kit.Default(arg, ice.MISC) {
|
||||
m.Options(web.DOMAIN, web.UserHost(m), cli.CTX_ENV, kit.Select("", ice.SP+kit.JoinKV(ice.EQ, ice.SP, cli.CTX_POD, m.Option(ice.MSG_USERPOD)), m.Option(ice.MSG_USERPOD) != ""))
|
||||
m.Options(web.DOMAIN, web.UserHost(m), cli.CTX_ENV, kit.Select("", lex.SP+kit.JoinKV(mdb.EQ, lex.SP, cli.CTX_POD, m.Option(ice.MSG_USERPOD)), m.Option(ice.MSG_USERPOD) != ""))
|
||||
switch k {
|
||||
case INSTALL:
|
||||
m.Echo(strings.TrimSpace(nfs.Template(m, kit.Keys(ice.MISC, SH))))
|
||||
@ -73,7 +74,7 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
PUBLISH: {Name: "publish path auto create volcanos icebergs intshell", Help: "发布", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.VOLCANOS: {Help: "火山架", Hand: func(m *ice.Message, arg ...string) {
|
||||
_publish_list(m, kit.ExtReg(HTML, CSS, JS)).Cmdy("", ice.CONTEXTS, ice.MISC).Echo(ice.NL).EchoQRCode(m.Option(ice.MSG_USERWEB))
|
||||
_publish_list(m, kit.ExtReg(HTML, CSS, JS)).Cmdy("", ice.CONTEXTS, ice.MISC).Echo(lex.NL).EchoQRCode(m.Option(ice.MSG_USERWEB))
|
||||
}},
|
||||
ice.ICEBERGS: {Help: "冰山架", Hand: func(m *ice.Message, arg ...string) {
|
||||
_publish_bin_list(m).Cmdy("", ice.CONTEXTS, ice.CORE)
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/ssh"
|
||||
@ -15,7 +16,7 @@ import (
|
||||
|
||||
func _sh_cmds(m *ice.Message, p string) (string, string) {
|
||||
cmds, text := kit.Select(SH, mdb.Config(m, ssh.SHELL)), kit.Format(strings.TrimSpace(nfs.Template(m, "cmd.sh")), web.UserHost(m), m.Option(ice.MSG_USERPOD), p)
|
||||
if head := kit.Select("", strings.Split(m.Cmdx(nfs.CAT, p), ice.NL), 0); strings.HasPrefix(head, "#!") {
|
||||
if head := kit.Select("", strings.Split(m.Cmdx(nfs.CAT, p), lex.NL), 0); strings.HasPrefix(head, "#!") {
|
||||
cmds = strings.TrimSpace(strings.TrimPrefix(head, "#!"))
|
||||
}
|
||||
return cmds, text
|
||||
@ -44,7 +45,7 @@ func init() {
|
||||
}},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
cmds, text := _sh_cmds(m, path.Join(arg[2], arg[1]))
|
||||
m.Cmdy(cli.SYSTEM, cmds, "-c", text).Status(ssh.SHELL, strings.ReplaceAll(text, ice.NL, "; "))
|
||||
m.Cmdy(cli.SYSTEM, cmds, "-c", text).Status(ssh.SHELL, strings.ReplaceAll(text, lex.NL, "; "))
|
||||
}},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(nfs.Template(m, "demo.sh")) }},
|
||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, "ctags", "-a", "-R", nfs.PWD) }},
|
||||
|
@ -9,6 +9,7 @@ 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/log"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
@ -20,11 +21,11 @@ import (
|
||||
|
||||
func _vimer_make(m *ice.Message, dir string, msg *ice.Message) {
|
||||
defer m.StatusTimeCount()
|
||||
for _, line := range strings.Split(msg.Append(cli.CMD_ERR), ice.NL) {
|
||||
if !strings.Contains(line, ice.DF) {
|
||||
for _, line := range strings.Split(msg.Append(cli.CMD_ERR), lex.NL) {
|
||||
if !strings.Contains(line, nfs.DF) {
|
||||
continue
|
||||
}
|
||||
if ls := strings.SplitN(line, ice.DF, 4); len(ls) > 3 {
|
||||
if ls := strings.SplitN(line, nfs.DF, 4); len(ls) > 3 {
|
||||
for i, p := range kit.Split(dir) {
|
||||
if strings.HasPrefix(ls[0], p) {
|
||||
m.Push(nfs.PATH, p)
|
||||
@ -32,7 +33,7 @@ func _vimer_make(m *ice.Message, dir string, msg *ice.Message) {
|
||||
m.Push(nfs.LINE, ls[1])
|
||||
m.Push(mdb.TEXT, ls[3])
|
||||
break
|
||||
} else if i == strings.Count(dir, ice.FS) {
|
||||
} else if i == strings.Count(dir, mdb.FS) {
|
||||
ps := nfs.SplitPath(m, ls[0])
|
||||
m.Push(nfs.PATH, ps[0])
|
||||
m.Push(nfs.FILE, ps[1])
|
||||
@ -61,7 +62,7 @@ func init() {
|
||||
m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, "main", mdb.TEXT, ice.SRC_MAIN_GO)
|
||||
m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, "main", mdb.TEXT, ice.SRC_MAIN_SH)
|
||||
m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, "main", mdb.TEXT, ice.SRC_MAIN_JS)
|
||||
m.PushSearch(mdb.TYPE, web.LINK, mdb.NAME, "admin", mdb.TEXT, web.MergeURL2(m, ice.PS, log.DEBUG, ice.TRUE))
|
||||
m.PushSearch(mdb.TYPE, web.LINK, mdb.NAME, "admin", mdb.TEXT, web.MergeURL2(m, nfs.PS, log.DEBUG, ice.TRUE))
|
||||
m.PushSearch(mdb.TYPE, web.LINK, mdb.NAME, m.CommandKey(), mdb.TEXT, m.MergePodCmd("", "", log.DEBUG, ice.TRUE))
|
||||
}
|
||||
}},
|
||||
@ -82,7 +83,7 @@ func init() {
|
||||
case nfs.FILE:
|
||||
list := ice.Map{}
|
||||
push := func(k, p string) {
|
||||
kit.IfNoKey(list, kit.Select(k, k+ice.DF, k != "")+p, func(p string) { m.Push(nfs.PATH, p) })
|
||||
kit.IfNoKey(list, kit.Select(k, k+nfs.DF, k != "")+p, func(p string) { m.Push(nfs.PATH, p) })
|
||||
}
|
||||
mdb.HashSelect(m.Spawn()).TablesLimit(30, func(value ice.Maps) { push("", value[nfs.PATH]) })
|
||||
m.Cmd(mdb.SEARCH, mdb.FOREACH, "", ice.OptionFields("type,name,text")).Sort("type,name,text").Table(func(value ice.Maps) {
|
||||
@ -153,7 +154,7 @@ func init() {
|
||||
isWebview := func() bool { return strings.HasSuffix(os.Args[0], _app) }
|
||||
cmds := []string{COMPILE, ice.SRC_MAIN_GO, ice.BIN_ICE_BIN}
|
||||
if isWebview() {
|
||||
m.Option(cli.ENV, "CGO_ENABLED", "1", cli.HOME, kit.Env(cli.HOME), cli.PATH, kit.Path(ice.USR_LOCAL_GO_BIN)+ice.DF+kit.Env(cli.PATH))
|
||||
m.Option(cli.ENV, "CGO_ENABLED", "1", cli.HOME, kit.Env(cli.HOME), cli.PATH, kit.Path(ice.USR_LOCAL_GO_BIN)+nfs.DF+kit.Env(cli.PATH))
|
||||
cmds = []string{COMPILE, ice.SRC_WEBVIEW_GO, path.Join(app, _app)}
|
||||
}
|
||||
if msg := m.Cmd(cmds); cli.IsSuccess(msg) {
|
||||
@ -195,7 +196,7 @@ func init() {
|
||||
})
|
||||
}
|
||||
func Complete(m *ice.Message, text string, data ice.Map) {
|
||||
if strings.HasSuffix(text, ice.PT) {
|
||||
if strings.HasSuffix(text, nfs.PT) {
|
||||
m.Push(mdb.TEXT, kit.Simple(data[kit.Slice(kit.Split(text, " ."), -1)[0]]))
|
||||
} else {
|
||||
m.Push(mdb.TEXT, data[""])
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"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/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -18,7 +19,7 @@ import (
|
||||
func _volcanos(m *ice.Message, p ...string) string { return ice.USR_VOLCANOS + path.Join(p...) }
|
||||
func _publish(m *ice.Message, p ...string) string { return ice.USR_PUBLISH + path.Join(p...) }
|
||||
func _require(m *ice.Message, p string) string {
|
||||
return path.Join(ice.PS, strings.TrimPrefix(strings.Replace(p, ice.USR_MODULES, "/require/modules/", 1), ice.USR_VOLCANOS))
|
||||
return path.Join(nfs.PS, strings.TrimPrefix(strings.Replace(p, ice.USR_MODULES, "/require/modules/", 1), ice.USR_VOLCANOS))
|
||||
}
|
||||
func _webpack_css(m *ice.Message, css, js io.Writer, p string) {
|
||||
fmt.Fprintln(css, kit.Format("/* %s */", _require(m, p)))
|
||||
@ -84,11 +85,11 @@ func _webpack_build(m *ice.Message, name string) {
|
||||
if f, p, e := nfs.CreateFile(m, kit.Keys(name, HTML)); m.Assert(e) {
|
||||
defer f.Close()
|
||||
defer m.Echo(p)
|
||||
fmt.Fprintf(f, nfs.Template(m, "index.html"), m.Cmdx(nfs.CAT, USR_PUBLISH_CAN_CSS), m.Cmdx(nfs.CAT, USR_PUBLISH_CAN_JS), kit.JoinKV(ice.EQ, ice.NL,
|
||||
fmt.Fprintf(f, nfs.Template(m, "index.html"), m.Cmdx(nfs.CAT, USR_PUBLISH_CAN_CSS), m.Cmdx(nfs.CAT, USR_PUBLISH_CAN_JS), kit.JoinKV(mdb.EQ, lex.NL,
|
||||
`Volcanos.meta.args`, kit.Formats(kit.Dict(m.OptionSimple(kit.Split(m.Option(ctx.ARGS))...))),
|
||||
`Volcanos.meta.pack`, kit.Formats(kit.UnMarshal(kit.Select("{}", m.Option(nfs.CONTENT)))),
|
||||
`Volcanos.meta.webpack`, ice.TRUE,
|
||||
)+ice.NL, m.Cmdx(nfs.CAT, ice.SRC_MAIN_JS))
|
||||
)+lex.NL, m.Cmdx(nfs.CAT, ice.SRC_MAIN_JS))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/log"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
@ -22,7 +23,7 @@ func _xterm_get(m *ice.Message, h string) *xterm.XTerm {
|
||||
m.Assert(h != "")
|
||||
mdb.HashModify(m, mdb.TIME, m.Time(), web.VIEW, m.Option(ice.MSG_DAEMON))
|
||||
return mdb.HashSelectTarget(m, h, func(value ice.Maps) ice.Any {
|
||||
text := strings.Split(value[mdb.TEXT], ice.NL)
|
||||
text := strings.Split(value[mdb.TEXT], lex.NL)
|
||||
ls := kit.Split(strings.Split(kit.Select(nfs.SH, value[mdb.TYPE]), " # ")[0])
|
||||
kit.If(value[nfs.PATH] != "" && !strings.HasSuffix(value[nfs.PATH], nfs.PS), func() { value[nfs.PATH] = path.Dir(value[nfs.PATH]) })
|
||||
term, e := xterm.Command(m, value[nfs.PATH], kit.Select(ls[0], cli.SystemFind(m, ls[0])), ls[1:]...)
|
||||
@ -32,7 +33,7 @@ func _xterm_get(m *ice.Message, h string) *xterm.XTerm {
|
||||
m.Go(func() {
|
||||
defer term.Close()
|
||||
defer mdb.HashRemove(m, mdb.HASH, h)
|
||||
m.Log(cli.START, strings.Join(term.Args, ice.SP))
|
||||
m.Log(cli.START, strings.Join(term.Args, lex.SP))
|
||||
buf := make([]byte, ice.MOD_BUFS)
|
||||
for {
|
||||
if n, e := term.Read(buf); !m.Warn(e) && e == nil {
|
||||
@ -40,7 +41,7 @@ func _xterm_get(m *ice.Message, h string) *xterm.XTerm {
|
||||
if cmd := text[0]; text[0] != "" {
|
||||
m.Go(func() {
|
||||
m.Sleep30ms()
|
||||
term.Write(cmd + ice.NL)
|
||||
term.Write(cmd + lex.NL)
|
||||
})
|
||||
}
|
||||
text = text[1:]
|
||||
@ -88,7 +89,7 @@ func init() {
|
||||
m.Cmdy(nfs.DIR, ice.USR_LOCAL_REPOS, nfs.PATH)
|
||||
m.Cmdy(nfs.DIR, ice.USR_LOCAL_DAEMON, nfs.PATH)
|
||||
case nfs.FILE:
|
||||
push := func(arg ...string) { m.Push(nfs.FILE, strings.Join(arg, ice.DF)) }
|
||||
push := func(arg ...string) { m.Push(nfs.FILE, strings.Join(arg, nfs.DF)) }
|
||||
m.Cmd("", func(value ice.Maps) {
|
||||
kit.If(value[mdb.TYPE] == web.LAYOUT, func() { push(web.LAYOUT, value[mdb.HASH], value[mdb.NAME]) })
|
||||
})
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -32,7 +34,7 @@ func (item *Item) Echo(str string, arg ...ice.Any) *Item {
|
||||
return item
|
||||
}
|
||||
func (item *Item) Dump(m *ice.Message) *ice.Message {
|
||||
return m.Echo(kit.Join(item.list, ice.SP), item.args...).Echo(ice.NL)
|
||||
return m.Echo(kit.Join(item.list, lex.SP), item.args...).Echo(lex.NL)
|
||||
}
|
||||
|
||||
type Group struct{ list ice.Messages }
|
||||
@ -61,11 +63,11 @@ func (g *Group) EchoLine(group string, x1, y1, x2, y2 int) *ice.Message {
|
||||
}
|
||||
func (g *Group) EchoRect(group string, height, width, x, y int, arg ...string) *ice.Message { // rx ry
|
||||
return g.Echo(group, `<rect height=%d width=%d rx=%s ry=%s x=%d y=%d %s/>`,
|
||||
height, width, kit.Select("4", arg, 0), kit.Select("4", arg, 1), x, y, kit.JoinKV(ice.EQ, ice.SP, kit.Slice(arg, 2)...))
|
||||
height, width, kit.Select("4", arg, 0), kit.Select("4", arg, 1), x, y, kit.JoinKV(mdb.EQ, lex.SP, kit.Slice(arg, 2)...))
|
||||
}
|
||||
func (g *Group) EchoText(group string, x, y int, text string, arg ...string) *ice.Message {
|
||||
float := kit.Int(kit.Select("2", "6", strings.Contains(g.Get(group).Option(ice.MSG_USERUA), "Chrome")))
|
||||
return g.Echo(group, "<text x=%d y=%d %s>%s</text>", x, y+float, kit.JoinKV(ice.EQ, ice.SP, arg...), text)
|
||||
return g.Echo(group, "<text x=%d y=%d %s>%s</text>", x, y+float, kit.JoinKV(mdb.EQ, lex.SP, arg...), text)
|
||||
}
|
||||
func (g *Group) EchoTexts(group string, x, y int, text string, arg ...string) *ice.Message {
|
||||
m := g.Get(group)
|
||||
|
@ -20,7 +20,7 @@ func (c *Chain) Init(m *ice.Message, arg ...string) wiki.Chart {
|
||||
const _DEEP = "_deep"
|
||||
stack, max := kit.List(kit.Dict(_DEEP, -1, wiki.WIDTH, "0")), 0
|
||||
last := func(key string) int { return kit.Int(kit.Value(stack[len(stack)-1], key)) }
|
||||
m.Cmd(lex.SPLIT, "", mdb.TEXT, kit.Dict(lex.SPLIT_BLOCK, ice.SP, nfs.CAT_CONTENT, arg[0]), func(deep int, ls []string, data, root ice.Map) {
|
||||
m.Cmd(lex.SPLIT, "", mdb.TEXT, kit.Dict(lex.SPLIT_BLOCK, lex.SP, nfs.CAT_CONTENT, arg[0]), func(deep int, ls []string, data, root ice.Map) {
|
||||
for deep <= last(_DEEP) {
|
||||
stack = stack[:len(stack)-1]
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ type Label struct {
|
||||
func (s *Label) Init(m *ice.Message, arg ...string) wiki.Chart {
|
||||
(&s.Block).Init(m)
|
||||
s.max = map[int]int{}
|
||||
m.Cmd(lex.SPLIT, "", kit.Dict(lex.SPLIT_BLOCK, ice.SP, nfs.CAT_CONTENT, arg[0]), func(ls []string) {
|
||||
m.Cmd(lex.SPLIT, "", kit.Dict(lex.SPLIT_BLOCK, lex.SP, nfs.CAT_CONTENT, arg[0]), func(ls []string) {
|
||||
s.data = append(s.data, ls)
|
||||
for i, v := range ls {
|
||||
if w := s.GetWidth(kit.SplitWord(v)[0]); w > s.max[i] {
|
||||
|
@ -26,7 +26,7 @@ func (s *Sequence) push(m *ice.Message, list string, arg ...ice.Any) ice.Map {
|
||||
}
|
||||
func (s *Sequence) Init(m *ice.Message, arg ...string) wiki.Chart {
|
||||
(&s.Block).Init(m)
|
||||
m.Cmd(lex.SPLIT, "", kit.Dict(lex.SPLIT_BLOCK, ice.SP, nfs.CAT_CONTENT, arg[0]), func(ls []string) {
|
||||
m.Cmd(lex.SPLIT, "", kit.Dict(lex.SPLIT_BLOCK, lex.SP, nfs.CAT_CONTENT, arg[0]), func(ls []string) {
|
||||
if len(s.head) == 0 {
|
||||
s.head, s.pos = ls, make([]int, len(ls))
|
||||
for i := 0; i < len(ls); i++ {
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"path"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -23,10 +24,10 @@ func init() {
|
||||
}
|
||||
}},
|
||||
mdb.CREATE: {Name: "create path field value", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd("", nfs.SAVE, m.Option(nfs.PATH), kit.Join(kit.Split(m.Option(mdb.FIELD)))+ice.NL+kit.Join(kit.Split(m.Option(mdb.VALUE)))+ice.NL)
|
||||
m.Cmd("", nfs.SAVE, m.Option(nfs.PATH), kit.Join(kit.Split(m.Option(mdb.FIELD)))+lex.NL+kit.Join(kit.Split(m.Option(mdb.VALUE)))+lex.NL)
|
||||
}},
|
||||
nfs.PUSH: {Name: "push path record", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(nfs.PUSH, path.Join(mdb.Config(m, nfs.PATH), arg[0]), kit.Join(arg[1:], ice.FS)+ice.NL)
|
||||
m.Cmd(nfs.PUSH, path.Join(mdb.Config(m, nfs.PATH), arg[0]), kit.Join(arg[1:], mdb.FS)+lex.NL)
|
||||
}}, "draw": {Help: "绘图"},
|
||||
}, WikiAction(ice.USR_LOCAL_EXPORT, nfs.CSV)), Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(!_wiki_list(m, arg...), func() { CSV(m, m.Cmdx(nfs.CAT, arg[0])).StatusTimeCount() })
|
||||
|
@ -29,7 +29,7 @@ func init() {
|
||||
arg[0] = nfs.JSON
|
||||
} else if strings.HasPrefix(arg[1], web.HTTP) {
|
||||
arg[0] = web.HTTP
|
||||
} else if strings.Contains(arg[1], ice.EQ) {
|
||||
} else if strings.Contains(arg[1], mdb.EQ) {
|
||||
arg[0] = web.FORM
|
||||
} else if _, e := strconv.ParseInt(arg[1], 10, 64); e == nil {
|
||||
arg[0] = mdb.TIME
|
||||
|
@ -14,7 +14,7 @@ func _refer_show(m *ice.Message, text string, arg ...string) {
|
||||
for _, v := range kit.SplitLine(text) {
|
||||
if ls := kit.SplitWord(v); len(ls) == 1 {
|
||||
p := kit.QueryUnescape(ls[0])
|
||||
list = append(list, []string{kit.Select(ls[0], path.Base(strings.Split(p, ice.QS)[0])), ls[0], p})
|
||||
list = append(list, []string{kit.Select(ls[0], path.Base(strings.Split(p, mdb.QS)[0])), ls[0], p})
|
||||
} else {
|
||||
list = append(list, append(ls, kit.QueryUnescape(ls[1])))
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -13,7 +14,7 @@ func _spark_md(m *ice.Message, arg ...string) *ice.Message {
|
||||
block, code := "", []string{}
|
||||
text := func() {
|
||||
if len(code) > 0 {
|
||||
m.Cmdy(SPARK, kit.Join(code, ice.NL))
|
||||
m.Cmdy(SPARK, kit.Join(code, lex.NL))
|
||||
code = []string{}
|
||||
}
|
||||
}
|
||||
@ -30,7 +31,7 @@ func _spark_md(m *ice.Message, arg ...string) *ice.Message {
|
||||
text()
|
||||
block = "```"
|
||||
} else {
|
||||
m.Cmdy(SPARK, SHELL, kit.Join(code, ice.NL))
|
||||
m.Cmdy(SPARK, SHELL, kit.Join(code, lex.NL))
|
||||
block, code = "", []string{}
|
||||
}
|
||||
return
|
||||
|
@ -26,11 +26,11 @@ func _wiki_path(m *ice.Message, arg ...string) string {
|
||||
return path.Join(mdb.Config(m, nfs.PATH), path.Join(arg...))
|
||||
}
|
||||
func _wiki_link(m *ice.Message, text string) string {
|
||||
kit.If(!kit.HasPrefix(text, ice.PS, ice.HTTP), func() { text = path.Join(web.SHARE_LOCAL, _wiki_path(m, text)) })
|
||||
kit.If(!kit.HasPrefix(text, nfs.PS, ice.HTTP), func() { text = path.Join(web.SHARE_LOCAL, _wiki_path(m, text)) })
|
||||
return text
|
||||
}
|
||||
func _wiki_list(m *ice.Message, arg ...string) bool {
|
||||
if m.Option(nfs.DIR_ROOT, _wiki_path(m)); len(arg) == 0 || kit.HasSuffix(arg[0], ice.PS) {
|
||||
if m.Option(nfs.DIR_ROOT, _wiki_path(m)); len(arg) == 0 || kit.HasSuffix(arg[0], nfs.PS) {
|
||||
kit.If(m.Option(nfs.DIR_DEEP) != ice.TRUE, func() { m.Cmdy(nfs.DIR, kit.Slice(arg, 0, 1), kit.Dict(nfs.DIR_TYPE, nfs.DIR)) })
|
||||
m.Cmdy(nfs.DIR, kit.Slice(arg, 0, 1), kit.Dict(nfs.DIR_TYPE, nfs.CAT, nfs.DIR_REG, mdb.Config(m, lex.REGEXP)))
|
||||
m.SortStrR(mdb.TIME).StatusTimeCount()
|
||||
@ -97,12 +97,12 @@ func (m *Message) OptionTemplate() string {
|
||||
kit.For(kit.Split("type,name,text"), func(k string) { add("data-", k) })
|
||||
kit.For(m.Optionv(mdb.EXTRA), func(k string, v string) { kit.If(!strings.Contains(k, "-"), func() { add("data-", k) }) })
|
||||
kit.For(kit.Split(ctx.STYLE), func(k string) { add("", k) })
|
||||
return kit.Join(res, ice.SP)
|
||||
return kit.Join(res, lex.SP)
|
||||
}
|
||||
func (m *Message) OptionKV(key ...string) string {
|
||||
res := []string{}
|
||||
kit.For(kit.Split(kit.Join(key)), func(k string) {
|
||||
kit.If(m.Option(k), func() { res = append(res, kit.Format("%s='%s'", k, m.Option(k))) })
|
||||
})
|
||||
return kit.Join(res, ice.SP)
|
||||
return kit.Join(res, lex.SP)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"shylinux.com/x/ice"
|
||||
"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/nfs"
|
||||
"shylinux.com/x/icebergs/core/wiki"
|
||||
@ -38,7 +39,7 @@ func (s alpha) Load(m *ice.Message, arg ...string) {
|
||||
m.Cmd(mdb.IMPORT, m.PrefixKey(), prefix, mdb.LIST, m.Option(nfs.FILE))
|
||||
mdb.Conf(m, "", kit.Keys(prefix, kit.Keym(mdb.LIMIT)), 0)
|
||||
mdb.Conf(m, "", kit.Keys(prefix, kit.Keym(mdb.LEAST)), 0)
|
||||
m.Echo("%s: %d", lib, mdb.Grow(m, m.PrefixKey(), prefix, kit.Dict(WORD, ice.SP)))
|
||||
m.Echo("%s: %d", lib, mdb.Grow(m, m.PrefixKey(), prefix, kit.Dict(WORD, lex.SP)))
|
||||
}
|
||||
func (s alpha) List(m *ice.Message, arg ...string) {
|
||||
if len(arg) < 2 || arg[1] == "" {
|
||||
@ -53,7 +54,7 @@ func (s alpha) List(m *ice.Message, arg ...string) {
|
||||
}
|
||||
defer func() { kit.If(m.Length() > 0, func() { m.Cmd(cache{}, mdb.CREATE, m.AppendSimple()) }) }()
|
||||
m.OptionFields(ice.FIELDS_DETAIL)
|
||||
arg[1] = "^" + arg[1] + ice.FS
|
||||
arg[1] = "^" + arg[1] + mdb.FS
|
||||
}
|
||||
wiki.CSV(m.Message.Spawn(), m.Cmdx(cli.SYSTEM, "grep", "-rih", arg[1], mdb.Config(m, mdb.STORE)), kit.Split(mdb.Config(m, mdb.FIELD))...).Table(func(value ice.Maps) {
|
||||
kit.If(m.FieldsIsDetail(), func() { m.PushDetail(value, mdb.Config(m, mdb.FIELD)) }, func() { m.PushRecord(value, mdb.Config(m, mdb.FIELD)) })
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
)
|
||||
|
||||
@ -14,8 +15,8 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
web.P(CONFIGS): {Hand: func(m *ice.Message, arg ...string) {
|
||||
if strings.Contains(m.Option(cli.RELEASE), cli.ALPINE) {
|
||||
m.Echo("sed -i 's/dl-cdn.alpinelinux.org/mirrors.tencent.com/g' /etc/apk/repositories && apk update").Echo(ice.NL)
|
||||
m.Echo("TZ=Asia/Shanghai; apk add tzdata && cp /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone").Echo(ice.NL)
|
||||
m.Echo("sed -i 's/dl-cdn.alpinelinux.org/mirrors.tencent.com/g' /etc/apk/repositories && apk update").Echo(lex.NL)
|
||||
m.Echo("TZ=Asia/Shanghai; apk add tzdata && cp /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone").Echo(lex.NL)
|
||||
}
|
||||
}},
|
||||
})
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -29,7 +30,7 @@ func init() {
|
||||
m.Optionv(ice.MSG_UPLOAD, web.UPLOAD)
|
||||
up := web.Upload(m)
|
||||
m.Cmd(FAVOR, mdb.INSERT, _DOWNLOAD, mdb.TYPE, kit.Ext(up[1]), mdb.NAME, up[1], mdb.TEXT, up[0], m.OptionSimple(cli.PWD, aaa.USERNAME, tcp.HOSTNAME))
|
||||
m.Echo(up[0]).Echo(ice.NL)
|
||||
m.Echo(up[0]).Echo(lex.NL)
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
@ -34,7 +35,7 @@ ish_sys_dev_run_source() {
|
||||
ish_sys_dev_source $url
|
||||
done
|
||||
}
|
||||
`, kit.Join(list, ice.SP), arg[0], kit.Join(args, ice.NL))
|
||||
`, kit.Join(list, lex.SP), arg[0], kit.Join(args, lex.NL))
|
||||
m.Echo(`
|
||||
ish_sys_dev_run_action() {
|
||||
select action in %s; do
|
||||
@ -46,7 +47,7 @@ ish_sys_dev_run_action() {
|
||||
echo
|
||||
done
|
||||
}
|
||||
`, kit.Join(list, ice.SP), arg[0], kit.Join(args, ice.NL))
|
||||
`, kit.Join(list, lex.SP), arg[0], kit.Join(args, lex.NL))
|
||||
m.Echo(`
|
||||
ish_sys_dev_run_command() {
|
||||
ish_sys_dev_run %s "$@"
|
||||
@ -66,11 +67,11 @@ func init() {
|
||||
if len(list) == kit.Int(m.Option("cword")) {
|
||||
list = kit.Slice(list, 0, -1)
|
||||
}
|
||||
m.Echo(strings.Join(Complete(m, false, list...), ice.NL))
|
||||
m.Echo(strings.Join(Complete(m, false, list...), lex.NL))
|
||||
}},
|
||||
ctx.COMMAND: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Search(arg[0], func(_ *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
|
||||
if p := kit.ExtChange(kit.Select("/app/cat.sh", cmd.Meta[ctx.DISPLAY]), nfs.SH); strings.HasPrefix(p, ice.PS+ice.REQUIRE) {
|
||||
if p := kit.ExtChange(kit.Select("/app/cat.sh", cmd.Meta[ctx.DISPLAY]), nfs.SH); strings.HasPrefix(p, nfs.PS+ice.REQUIRE) {
|
||||
m.Cmdy(web.SPIDE, ice.DEV, web.SPIDE_RAW, p)
|
||||
} else {
|
||||
m.Cmdy(nfs.CAT, path.Join(ice.USR_INTSHELL, p))
|
||||
@ -82,8 +83,8 @@ func init() {
|
||||
if !ctx.PodCmd(m, arg) && aaa.Right(m, arg) {
|
||||
m.Cmdy(arg)
|
||||
}
|
||||
if m.Result() != "" && !strings.HasSuffix(m.Result(), ice.NL) {
|
||||
m.Echo(ice.NL)
|
||||
if m.Result() != "" && !strings.HasSuffix(m.Result(), lex.NL) {
|
||||
m.Echo(lex.NL)
|
||||
}
|
||||
}},
|
||||
}},
|
||||
@ -95,17 +96,17 @@ func Complete(m *ice.Message, detail bool, arg ...string) (res []string) {
|
||||
if len(arg) < 2 || arg[1] != ctx.ACTION {
|
||||
list := ctx.CmdList(m.Spawn()).Appendv(ctx.INDEX)
|
||||
if len(arg) > 0 {
|
||||
pre := arg[0][0 : strings.LastIndex(arg[0], ice.PT)+1]
|
||||
pre := arg[0][0 : strings.LastIndex(arg[0], nfs.PT)+1]
|
||||
list = kit.Simple(list, func(cmd string) bool { return strings.HasPrefix(cmd, arg[0]) }, func(cmd string) string { return strings.TrimPrefix(cmd, pre) })
|
||||
}
|
||||
if len(arg) > 1 || (len(list) == 1 && kit.Select("", kit.Split(arg[0], ice.PT), -1) == list[0]) {
|
||||
if len(arg) > 1 || (len(list) == 1 && kit.Select("", kit.Split(arg[0], nfs.PT), -1) == list[0]) {
|
||||
kit.If(detail, func() { echo("func") })
|
||||
m.Cmdy(arg).Search(arg[0], func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
|
||||
field := kit.Format(kit.Value(cmd.List, kit.Keys(len(arg)-1, mdb.NAME)))
|
||||
m.Table(func(index int, value ice.Maps, head []string) {
|
||||
echo(value[field])
|
||||
if detail {
|
||||
echo(kit.Join(kit.Simple(head, func(key string) string { return key + ": " + value[key] }), ice.SP))
|
||||
echo(kit.Join(kit.Simple(head, func(key string) string { return key + ": " + value[key] }), lex.SP))
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -129,7 +130,7 @@ func Complete(m *ice.Message, detail bool, arg ...string) (res []string) {
|
||||
m.Options(arg[3:])
|
||||
m.Cmdy(arg[0], mdb.INPUTS, kit.Select("", arg, -1)).Table(func(value ice.Maps) {
|
||||
v := value[m.Appendv(ice.MSG_APPEND)[0]]
|
||||
kit.If(strings.Contains(v, ice.SP), func() { echo("\"" + v + "\"") }, func() { echo(v) })
|
||||
kit.If(strings.Contains(v, lex.SP), func() { echo("\"" + v + "\"") }, func() { echo(v) })
|
||||
})
|
||||
}
|
||||
return
|
||||
@ -140,7 +141,7 @@ func Complete(m *ice.Message, detail bool, arg ...string) (res []string) {
|
||||
kit.For(kit.SortedKey(cmd.Actions), func(sub string) {
|
||||
if strings.HasPrefix(sub, kit.Select("", arg, 2)) {
|
||||
if echo(sub); detail {
|
||||
echo(cmd.Actions[sub].Name + ice.SP + cmd.Actions[sub].Help)
|
||||
echo(cmd.Actions[sub].Name + lex.SP + cmd.Actions[sub].Help)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -7,6 +7,7 @@ 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/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -42,9 +43,9 @@ func init() {
|
||||
}},
|
||||
web.PP(SYNC): {Actions: ice.Actions{
|
||||
HISTORY: {Hand: func(m *ice.Message, arg ...string) {
|
||||
ls := strings.SplitN(strings.TrimSpace(m.Option(ARG)), ice.SP, 4)
|
||||
if text := strings.TrimSpace(strings.Join(ls[3:], ice.SP)); text != "" {
|
||||
m.Cmd(SYNC, mdb.INSERT, mdb.TIME, ls[1]+ice.SP+ls[2], mdb.TYPE, SHELL, mdb.NAME, ls[0], mdb.TEXT, text, m.OptionSimple(cli.PWD, aaa.USERNAME, tcp.HOSTNAME))
|
||||
ls := strings.SplitN(strings.TrimSpace(m.Option(ARG)), lex.SP, 4)
|
||||
if text := strings.TrimSpace(strings.Join(ls[3:], lex.SP)); text != "" {
|
||||
m.Cmd(SYNC, mdb.INSERT, mdb.TIME, ls[1]+lex.SP+ls[2], mdb.TYPE, SHELL, mdb.NAME, ls[0], mdb.TEXT, text, m.OptionSimple(cli.PWD, aaa.USERNAME, tcp.HOSTNAME))
|
||||
}
|
||||
}},
|
||||
}},
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -12,7 +13,7 @@ import (
|
||||
func _configs_set(m *ice.Message, k, v string) string { return _git_cmds(m, CONFIG, "--global", k, v) }
|
||||
func _configs_get(m *ice.Message, k string) string { return _git_cmds(m, CONFIG, "--global", k) }
|
||||
func _configs_list(m *ice.Message) *ice.Message {
|
||||
kit.SplitKV(ice.EQ, ice.NL, _configs_get(m, "--list"), func(text string, ls []string) {
|
||||
kit.SplitKV(mdb.EQ, lex.NL, _configs_get(m, "--list"), func(text string, ls []string) {
|
||||
m.Push(mdb.NAME, ls[0]).Push(mdb.VALUE, ls[1]).PushButton(mdb.REMOVE)
|
||||
})
|
||||
return mdb.HashSelectValue(m, func(value ice.Maps) { m.Push("", value, kit.Split("name,value")).PushButton(mdb.CREATE) })
|
||||
@ -21,7 +22,7 @@ func _configs_read(m *ice.Message, p string) ice.Maps {
|
||||
res, block := ice.Maps{}, ""
|
||||
m.Cmd(nfs.CAT, p, func(text string) {
|
||||
if strings.HasPrefix(text, "[") {
|
||||
block = kit.Join(kit.Split(text, " []"), ice.PT)
|
||||
block = kit.Join(kit.Split(text, " []"), nfs.PT)
|
||||
return
|
||||
}
|
||||
ls := kit.Split(text, " =")
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/core/code"
|
||||
@ -67,7 +68,7 @@ func init() {
|
||||
"tags": {Help: "索引", Hand: func(m *ice.Message, arg ...string) {
|
||||
count := map[string]int{}
|
||||
m.Cmd(nfs.CAT, path.Join(arg[0], nfs.TAGS), func(line string) {
|
||||
if ls := strings.SplitN(line, ice.TB, 3); len(ls) < 3 {
|
||||
if ls := strings.SplitN(line, lex.TB, 3); len(ls) < 3 {
|
||||
return
|
||||
} else if ls = strings.SplitN(ls[2], ";\"", 2); len(ls) < 2 {
|
||||
return
|
||||
|
@ -18,6 +18,7 @@ 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/log"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
@ -59,7 +60,7 @@ func _repos_each(m *ice.Message, title string, cb func(*git.Repository, ice.Maps
|
||||
if msg.Length() == 0 {
|
||||
return
|
||||
}
|
||||
web.GoToast(m, kit.Select(m.CommandKey()+ice.SP+m.ActionKey(), title), func(toast func(string, int, int)) {
|
||||
web.GoToast(m, kit.Select(m.CommandKey()+lex.SP+m.ActionKey(), title), func(toast func(string, int, int)) {
|
||||
list, count, total := []string{}, 0, msg.Length()
|
||||
msg.Table(func(value ice.Maps) {
|
||||
toast(value[REPOS], count, total)
|
||||
@ -71,7 +72,7 @@ func _repos_each(m *ice.Message, title string, cb func(*git.Repository, ice.Maps
|
||||
count++
|
||||
})
|
||||
if len(list) > 0 {
|
||||
web.Toast(m, strings.Join(list, ice.NL), ice.FAILURE, "30s")
|
||||
web.Toast(m, strings.Join(list, lex.NL), ice.FAILURE, "30s")
|
||||
} else {
|
||||
toast(ice.SUCCESS, count, total)
|
||||
}
|
||||
@ -157,12 +158,12 @@ func _repos_status(m *ice.Message, p string, repos *git.Repository) error {
|
||||
}
|
||||
defer m.StatusTimeCount()
|
||||
for k, v := range status {
|
||||
if kit.IsIn(kit.Ext(k), "swp", "swo") {
|
||||
if kit.IsIn(kit.Ext(k), "swp", "swo") || kit.IsIn(kit.Split(k, nfs.PS)[0], ice.BIN, ice.VAR, ice.USR) {
|
||||
continue
|
||||
}
|
||||
if m.Push(REPOS, p).Push(STATUS, string(v.Worktree)+string(v.Staging)).Push(nfs.FILE, k); m.Option("mode") == "zone" {
|
||||
if m.Push(REPOS, p).Push(STATUS, string(v.Worktree)+string(v.Staging)).Push(nfs.FILE, k); m.Option(ice.MSG_MODE) == mdb.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])
|
||||
m.Push(nfs.PATH, ls[0]).Push(mdb.TEXT, string(v.Worktree)+string(v.Staging)+lex.SP+ls[0]+ls[1])
|
||||
}
|
||||
switch v.Worktree {
|
||||
case git.Untracked:
|
||||
@ -209,14 +210,15 @@ func _repos_vimer(m *ice.Message, _repos_path func(m *ice.Message, p string, arg
|
||||
} else if kit.Select("", arg, 1) != ctx.ACTION {
|
||||
if ls := kit.Split(path.Join(m.Option(nfs.DIR_ROOT), arg[1]), nfs.PS); len(ls) < 2 || ls[2] == INDEX {
|
||||
if repos := _repos_open(m, ls[0]); len(arg) < 3 {
|
||||
// m.Cmdy(nfs.DIR, nfs.PWD, kit.Dict(nfs.DIR_ROOT, _repos_path(m, ls[0])))
|
||||
if work, err := repos.Worktree(); err == nil {
|
||||
if status, err := work.Status(); err == nil {
|
||||
for k := range status {
|
||||
m.Echo(k)
|
||||
m.Push(nfs.PATH, k)
|
||||
// m.Echo(k)
|
||||
}
|
||||
}
|
||||
}
|
||||
m.Cmdy(nfs.DIR, nfs.PWD, kit.Dict(nfs.DIR_ROOT, _repos_path(m, ls[0])))
|
||||
} else {
|
||||
m.Cmdy(nfs.CAT, _repos_path(m, ls[0], arg[2]))
|
||||
if refer, err := repos.Head(); err == nil {
|
||||
@ -313,7 +315,7 @@ func init() {
|
||||
p := path.Join(kit.Select(ice.USR_REQUIRE, m.Cmdx(cli.SYSTEM, "go", "env", "GOMODCACHE")), path.Join(arg...))
|
||||
if !nfs.Exists(m, p) {
|
||||
if p = path.Join(ice.USR_REQUIRE, path.Join(arg...)); !nfs.Exists(m, p) {
|
||||
ls := strings.SplitN(path.Join(arg[:3]...), ice.AT, 2)
|
||||
ls := strings.SplitN(path.Join(arg[:3]...), mdb.AT, 2)
|
||||
to := path.Join(ice.USR_REQUIRE, path.Join(arg[:3]...))
|
||||
_, err := git.PlainClone(to, false, &git.CloneOptions{URL: "https://" + ls[0], ReferenceName: plumbing.NewBranchReferenceName(kit.Select(ice.Info.Gomod[ls[0]], ls, 1))})
|
||||
m.Warn(err)
|
||||
@ -408,7 +410,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err := work.Commit(m.Option("actions")+ice.SP+m.Option("comment"), opt)
|
||||
_, err := work.Commit(m.Option("actions")+lex.SP+m.Option("comment"), opt)
|
||||
m.Warn(err)
|
||||
}
|
||||
}},
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -26,11 +27,11 @@ import (
|
||||
func _service_login(m *ice.Message) error {
|
||||
if ice.Info.Localhost && tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
||||
return nil
|
||||
} else if auth := strings.SplitN(m.R.Header.Get(web.Authorization), ice.SP, 2); strings.ToLower(auth[0]) != "basic" {
|
||||
} else if auth := strings.SplitN(m.R.Header.Get(web.Authorization), lex.SP, 2); strings.ToLower(auth[0]) != "basic" {
|
||||
return fmt.Errorf("Authentication type error")
|
||||
} else if data, err := base64.StdEncoding.DecodeString(auth[1]); err != nil {
|
||||
return err
|
||||
} else if auth := strings.SplitN(string(data), ice.DF, 2); m.Cmdv(Prefix(TOKEN), auth[0], TOKEN) != auth[1] {
|
||||
} else if auth := strings.SplitN(string(data), nfs.DF, 2); m.Cmdv(Prefix(TOKEN), auth[0], TOKEN) != auth[1] {
|
||||
return fmt.Errorf("username or password error")
|
||||
} else if aaa.UserRole(m, auth[0]) == aaa.VOID {
|
||||
return fmt.Errorf("userrole has no right")
|
||||
@ -51,7 +52,7 @@ func _service_repos(m *ice.Message, arg ...string) error {
|
||||
if m.Option(cli.CMD_DIR, repos); strings.HasSuffix(path.Join(arg...), INFO_REFS) {
|
||||
m.Option(ice.MSG_USERROLE, aaa.TECH)
|
||||
web.RenderType(m.W, "", kit.Format("application/x-git-%s-advertisement", service))
|
||||
_service_writer(m, "# service=git-"+service+ice.NL, _git_cmds(m, service, "--stateless-rpc", "--advertise-refs", ice.PT))
|
||||
_service_writer(m, "# service=git-"+service+lex.NL, _git_cmds(m, service, "--stateless-rpc", "--advertise-refs", nfs.PT))
|
||||
return nil
|
||||
}
|
||||
reader, err := _service_reader(m)
|
||||
@ -60,7 +61,7 @@ func _service_repos(m *ice.Message, arg ...string) error {
|
||||
}
|
||||
defer reader.Close()
|
||||
web.RenderType(m.W, "", kit.Format("application/x-git-%s-result", service))
|
||||
_git_cmd(m.Options(cli.CMD_INPUT, reader, cli.CMD_OUTPUT, m.W), service, "--stateless-rpc", ice.PT)
|
||||
_git_cmd(m.Options(cli.CMD_INPUT, reader, cli.CMD_OUTPUT, m.W), service, "--stateless-rpc", nfs.PT)
|
||||
return nil
|
||||
}
|
||||
func _service_writer(m *ice.Message, cmd string, str ...string) {
|
||||
|
@ -18,7 +18,7 @@ func init() {
|
||||
m.Cmdy(REPOS)
|
||||
} else if len(arg) == 1 {
|
||||
nfs.DirDeepAll(m, _repos_path(m, arg[0]), "", func(value ice.Maps) { m.Push("", value, []string{nfs.PATH}) }, nfs.PATH)
|
||||
m.Options(nfs.DIR_ROOT, _repos_path(m, arg[0])).StatusTimeCount()
|
||||
m.Options(nfs.DIR_ROOT, _repos_path(m, arg[0])+nfs.PS).StatusTimeCount()
|
||||
ctx.DisplayStory(m, "", mdb.FIELD, nfs.PATH, aaa.ROOT, arg[0])
|
||||
}
|
||||
}},
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -20,7 +21,7 @@ func _status_tag(m *ice.Message, tags string) string {
|
||||
if tags == "" {
|
||||
return "v0.0.1"
|
||||
}
|
||||
ls := kit.Split(strings.TrimPrefix(kit.Split(tags, "-")[0], "v"), ice.PT)
|
||||
ls := kit.Split(strings.TrimPrefix(kit.Split(tags, "-")[0], "v"), nfs.PT)
|
||||
if v := kit.Int(ls[2]); v < 9 {
|
||||
return kit.Format("v%v.%v.%v", ls[0], ls[1], v+1)
|
||||
} else if v := kit.Int(ls[1]); v < 9 {
|
||||
@ -32,7 +33,7 @@ func _status_tag(m *ice.Message, tags string) string {
|
||||
}
|
||||
}
|
||||
func _status_stat(m *ice.Message, files, adds, dels int) (int, int, int) {
|
||||
kit.SplitKV(ice.SP, ice.FS, _git_diff(m), func(text string, ls []string) {
|
||||
kit.SplitKV(lex.SP, mdb.FS, _git_diff(m), func(text string, ls []string) {
|
||||
n := kit.Int(ls[0])
|
||||
switch {
|
||||
case strings.Contains(text, "file"):
|
||||
@ -54,7 +55,7 @@ func _status_list(m *ice.Message) (files, adds, dels int, last string) {
|
||||
_last := m.Cmdv(REPOS, path.Base(value[nfs.PATH]), mdb.TIME)
|
||||
kit.If(_last > last, func() { last = _last })
|
||||
tags := _git_tags(m)
|
||||
kit.SplitKV(ice.SP, ice.NL, _git_status(m), func(text string, ls []string) {
|
||||
kit.SplitKV(lex.SP, lex.NL, _git_status(m), func(text string, ls []string) {
|
||||
switch kit.Ext(ls[1]) {
|
||||
case "swp", "swo", ice.BIN, ice.VAR:
|
||||
return
|
||||
@ -63,7 +64,7 @@ func _status_list(m *ice.Message) (files, adds, dels int, last string) {
|
||||
return
|
||||
}
|
||||
if m.Push(REPOS, value[REPOS]).Push(mdb.TYPE, ls[0]).Push(nfs.FILE, ls[1]); onlychange {
|
||||
m.Push(nfs.PATH, value[nfs.PATH]).Push(mdb.VIEW, kit.Format("%s %s", ls[0]+strings.Repeat(ice.SP, len(ls[0])-9), kit.Select("", nfs.USR+value[REPOS]+nfs.PS, value[REPOS] != ice.CONTEXTS)+ls[1]))
|
||||
m.Push(nfs.PATH, value[nfs.PATH]).Push(mdb.VIEW, kit.Format("%s %s", ls[0]+strings.Repeat(lex.SP, len(ls[0])-9), kit.Select("", nfs.USR+value[REPOS]+nfs.PS, value[REPOS] != ice.CONTEXTS)+ls[1]))
|
||||
}
|
||||
switch ls[0] {
|
||||
case "##":
|
||||
@ -107,7 +108,7 @@ func init() {
|
||||
case INSTEADOF:
|
||||
switch arg[0] {
|
||||
case nfs.FROM:
|
||||
m.Push(arg[0], kit.MergeURL2(ice.Info.Make.Remote, ice.PS))
|
||||
m.Push(arg[0], kit.MergeURL2(ice.Info.Make.Remote, nfs.PS))
|
||||
case nfs.TO:
|
||||
m.Cmd(web.BROAD, func(value ice.Maps) { m.Push(arg[0], kit.Format("http://%s:%s/", value[tcp.HOST], value[tcp.PORT])) })
|
||||
}
|
||||
@ -116,8 +117,8 @@ func init() {
|
||||
switch arg[0] {
|
||||
case COMMENT:
|
||||
ls := kit.Split(m.Option(nfs.FILE), " /")
|
||||
m.Push(arg[0], kit.Join(kit.Slice(ls, -1), ice.PS))
|
||||
m.Push(arg[0], kit.Join(kit.Slice(ls, -2), ice.PS))
|
||||
m.Push(arg[0], kit.Join(kit.Slice(ls, -1), nfs.PS))
|
||||
m.Push(arg[0], kit.Join(kit.Slice(ls, -2), nfs.PS))
|
||||
m.Push(arg[0], m.Option(nfs.FILE))
|
||||
case VERSION:
|
||||
m.Push(VERSION, _status_tag(m, m.Option(TAGS)))
|
||||
@ -151,7 +152,7 @@ func init() {
|
||||
return
|
||||
}
|
||||
text := []string{}
|
||||
for _, line := range kit.Split(m.Cmdx(web.SPACE, m.Option(mdb.NAME), cli.SYSTEM, GIT, DIFF, "--shortstat"), ice.FS, ice.FS) {
|
||||
for _, line := range kit.Split(m.Cmdx(web.SPACE, m.Option(mdb.NAME), cli.SYSTEM, GIT, DIFF, "--shortstat"), mdb.FS, mdb.FS) {
|
||||
if list := kit.Split(line); strings.Contains(line, "file") {
|
||||
text = append(text, list[0]+" file")
|
||||
} else if strings.Contains(line, "ins") {
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -46,7 +47,7 @@ func init() {
|
||||
host, list := ice.Map{kit.ParseURL(m.Option(TOKEN)).Host: true}, []string{m.Option(TOKEN)}
|
||||
m.Cmd(nfs.CAT, kit.HomePath(FILE), func(line string) {
|
||||
kit.IfNoKey(host, kit.ParseURL(line).Host, func(p string) { list = append(list, line) })
|
||||
}).Cmd(nfs.SAVE, kit.HomePath(FILE), strings.Join(list, ice.NL)+ice.NL)
|
||||
}).Cmd(nfs.SAVE, kit.HomePath(FILE), strings.Join(list, lex.NL)+lex.NL)
|
||||
}},
|
||||
web.PP(GET): {Hand: func(m *ice.Message, arg ...string) {
|
||||
web.RenderOrigin(m.W, "*")
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"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/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -75,16 +76,16 @@ func init() {
|
||||
kit.If(len(arg) > 0 && arg[0] == mdb.TOTAL, func() { total, arg = true, arg[1:] })
|
||||
args := []string{"log", "--shortstat", "--pretty=commit: %ad %n%s", "--date=iso", "--reverse"}
|
||||
if len(arg) > 0 {
|
||||
arg[0] += kit.Select("", " 00:00:00", strings.Contains(arg[0], "-") && !strings.Contains(arg[0], ice.DF))
|
||||
arg[0] += kit.Select("", " 00:00:00", strings.Contains(arg[0], "-") && !strings.Contains(arg[0], nfs.DF))
|
||||
args = append(args, kit.Select("-n", "--since", strings.Contains(arg[0], "-")))
|
||||
args = append(args, arg...)
|
||||
} else {
|
||||
args = append(args, "-n", "30")
|
||||
}
|
||||
from, days, commit, adds, dels := "", 0, 0, 0, 0
|
||||
kit.SplitKV(ice.NL, "commit:", _git_cmds(m, args...), func(text string, ls []string) {
|
||||
kit.SplitKV(lex.NL, "commit:", _git_cmds(m, args...), func(text string, ls []string) {
|
||||
add, del := "0", "0"
|
||||
for _, v := range kit.Split(strings.TrimSpace(kit.Select("", ls, -1)), ice.FS) {
|
||||
for _, v := range kit.Split(strings.TrimSpace(kit.Select("", ls, -1)), mdb.FS) {
|
||||
switch {
|
||||
case strings.Contains(v, "inser"):
|
||||
add = kit.Split(v)[0]
|
||||
@ -94,7 +95,7 @@ func init() {
|
||||
}
|
||||
if total {
|
||||
if commit++; from == "" {
|
||||
hs := strings.Split(ls[0], ice.SP)
|
||||
hs := strings.Split(ls[0], lex.SP)
|
||||
if t, e := time.Parse("2006-01-02", hs[0]); e == nil {
|
||||
from, days = hs[0], int(time.Now().Sub(t).Hours())/24
|
||||
}
|
||||
|
@ -90,10 +90,10 @@ func (s input) List(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case LINE:
|
||||
case WORD:
|
||||
arg[1] = "^" + arg[1] + ice.FS
|
||||
arg[1] = "^" + arg[1] + mdb.FS
|
||||
}
|
||||
res := m.Cmdx(cli.SYSTEM, "grep", "-rn", arg[1], mdb.Config(m, mdb.STORE))
|
||||
bio := csv.NewReader(bytes.NewBufferString(strings.Replace(res, ice.DF, ice.FS, -1)))
|
||||
bio := csv.NewReader(bytes.NewBufferString(strings.Replace(res, nfs.DF, mdb.FS, -1)))
|
||||
for i := 0; i < kit.Int(10); i++ {
|
||||
if line, e := bio.Read(); e != nil {
|
||||
break
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
@ -26,11 +27,11 @@ func (w wubi) Input(m *ice.Message, arg ...string) {
|
||||
switch list := kit.Split(arg[0]); list[1] {
|
||||
case "add": // ice add 想你 shwq [9999 [person]]
|
||||
w.Insert(m, mdb.ZONE, kit.Select("person", list, 5), mdb.TEXT, list[2], cli.CODE, list[3], mdb.VALUE, kit.Select("999999", list, 4))
|
||||
m.Echo(list[3] + ice.NL)
|
||||
m.Echo(list[3] + lex.NL)
|
||||
}
|
||||
return
|
||||
}
|
||||
m.Cmd(w, WORD, arg[0], func(value ice.Maps) { m.Echo(value[mdb.TEXT] + ice.NL) })
|
||||
m.Cmd(w, WORD, arg[0], func(value ice.Maps) { m.Echo(value[mdb.TEXT] + lex.NL) })
|
||||
}
|
||||
|
||||
func init() { ice.CodeCtxCmd(wubi{}) }
|
||||
|
@ -25,7 +25,7 @@ func (s spring) Build(m *ice.Message) {
|
||||
s.Code.Stream(m, m.Option(nfs.PATH), MVN, "package")
|
||||
}
|
||||
func (s spring) Start(m *ice.Message, arg ...string) {
|
||||
s.Code.Daemon(m, m.Option(nfs.PATH), kit.Simple(JAVA, kit.Simple(arg, func(k, v string) string { return "-D" + k + ice.EQ + v }),
|
||||
s.Code.Daemon(m, m.Option(nfs.PATH), kit.Simple(JAVA, kit.Simple(arg, func(k, v string) string { return "-D" + k + mdb.EQ + v }),
|
||||
"-jar", kit.Format("target/%s-0.0.1-SNAPSHOT.jar", m.Option(mdb.NAME)))...)
|
||||
}
|
||||
func (s spring) List(m *ice.Message, arg ...string) {
|
||||
|
@ -3,6 +3,7 @@ package lark
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/chat"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -21,7 +22,7 @@ func init() {
|
||||
m.Cmd("web.chat./river", func(val ice.Maps) {
|
||||
m.Cmd("web.chat./river", val[mdb.HASH], chat.STORM, func(value ice.Maps) {
|
||||
list = append(list, kit.Keys(val[mdb.NAME], value[mdb.NAME]),
|
||||
ice.CMD, kit.Format([]string{HOME, val[mdb.HASH], value[mdb.HASH], val[mdb.NAME] + ice.PT + value[mdb.NAME]}))
|
||||
ice.CMD, kit.Format([]string{HOME, val[mdb.HASH], value[mdb.HASH], val[mdb.NAME] + nfs.PT + value[mdb.NAME]}))
|
||||
})
|
||||
})
|
||||
} else {
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/wiki"
|
||||
@ -87,7 +88,7 @@ func init() {
|
||||
"card": {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.For(kit.Value(m.Optionv(ice.MSG_USERDATA), "action.value"), func(k string, v string) { m.Option(k, v) })
|
||||
m.Cmdy(TALK, kit.Parse(nil, "", kit.Split(m.Option(ice.CMD))...))
|
||||
m.Cmd(SEND, m.Option(APP_ID), CHAT_ID, m.Option(OPEN_CHAT_ID), m.Option(wiki.TITLE)+ice.SP+m.Option(ice.CMD), m.Result())
|
||||
m.Cmd(SEND, m.Option(APP_ID), CHAT_ID, m.Option(OPEN_CHAT_ID), m.Option(wiki.TITLE)+lex.SP+m.Option(ice.CMD), m.Result())
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(OPEN_CHAT_ID) == "" {
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
@ -35,13 +36,13 @@ func init() {
|
||||
val := []string{}
|
||||
m.Table(func(index int, value ice.Maps, head []string) {
|
||||
kit.For(head, func(k string) { val = append(val, kit.Format("%s:\t%s", k, value[k])) })
|
||||
val = append(val, ice.NL)
|
||||
val = append(val, lex.NL)
|
||||
})
|
||||
_lark_post(m, m.Option(APP_ID), "/open-apis/message/v4/send/", web.SPIDE_DATA, kit.Formats(
|
||||
kit.Dict("msg_type", "interactive", "chat_id", m.Option(OPEN_CHAT_ID), "card", kit.Dict(
|
||||
"header", kit.Dict("title", kit.Dict("tag", "lark_md", "content", strings.Join(cmds, " "))),
|
||||
"elements", []ice.Any{kit.Dict("tag", "div", "fields", []ice.Any{
|
||||
kit.Dict("is_short", true, "text", kit.Dict("tag", "lark_md", "content", strings.Join(val, ice.NL))),
|
||||
kit.Dict("is_short", true, "text", kit.Dict("tag", "lark_md", "content", strings.Join(val, lex.NL))),
|
||||
})},
|
||||
)),
|
||||
))
|
||||
|
@ -96,7 +96,7 @@ const SPLIT = "split"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
SPLIT: {Name: "split path key auto", Help: "分词", Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 || strings.HasSuffix(arg[0], ice.PS) {
|
||||
if len(arg) == 0 || strings.HasSuffix(arg[0], nfs.PS) {
|
||||
m.Cmdy(nfs.DIR, arg)
|
||||
return
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
psh "shylinux.com/x/icebergs/base/ssh"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -49,7 +50,7 @@ func init() {
|
||||
ctx.COMMAND: {Name: "command cmd=pwd", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.ZoneInsert(m, m.OptionSimple(mdb.HASH), mdb.TYPE, CMD, mdb.TEXT, m.Option(CMD))
|
||||
if w, ok := mdb.HashSelectTarget(m, m.Option(mdb.HASH), nil).(io.Writer); ok {
|
||||
w.Write([]byte(m.Option(CMD) + ice.NL))
|
||||
w.Write([]byte(m.Option(CMD) + lex.NL))
|
||||
m.Sleep300ms()
|
||||
}
|
||||
}},
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
psh "shylinux.com/x/icebergs/base/ssh"
|
||||
@ -32,7 +33,7 @@ func _ssh_open(m *ice.Message, arg ...string) {
|
||||
c.Write([]byte(fmt.Sprintf("#height:%d,width:%d\n", h, w)))
|
||||
for _, item := range kit.Simple(m.Optionv(ice.INIT)) {
|
||||
m.Sleep300ms()
|
||||
c.Write([]byte(item + ice.NL))
|
||||
c.Write([]byte(item + lex.NL))
|
||||
}
|
||||
m.Go(func() { io.Copy(c, os.Stdin) })
|
||||
io.Copy(os.Stdout, c)
|
||||
@ -114,7 +115,7 @@ func _ssh_conn(m *ice.Message, cb func(*ssh.Client), arg ...string) {
|
||||
return
|
||||
}))
|
||||
m.Cmdy(tcp.CLIENT, tcp.DIAL, mdb.TYPE, SSH, mdb.NAME, m.Option(tcp.HOST), m.OptionSimple(tcp.HOST, tcp.PORT), arg, func(c net.Conn) {
|
||||
conn, chans, reqs, err := ssh.NewClientConn(c, m.Option(tcp.HOST)+ice.DF+m.Option(tcp.PORT), &ssh.ClientConfig{
|
||||
conn, chans, reqs, err := ssh.NewClientConn(c, m.Option(tcp.HOST)+nfs.DF+m.Option(tcp.PORT), &ssh.ClientConfig{
|
||||
User: m.Option(aaa.USERNAME), Auth: methods, BannerCallback: func(message string) error { return nil },
|
||||
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error { return nil },
|
||||
})
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -40,7 +41,7 @@ func init() {
|
||||
mdb.CREATE: {Name: "create bits=2048,4096 title=some", Hand: func(m *ice.Message, arg ...string) {
|
||||
if key, err := rsa.GenerateKey(rand.Reader, kit.Int(m.Option(BITS))); !m.Warn(err, ice.ErrNotValid) {
|
||||
if pub, err := ssh.NewPublicKey(key.Public()); !m.Warn(err, ice.ErrNotValid) {
|
||||
mdb.HashCreate(m, m.OptionSimple(TITLE), PUBLIC, string(ssh.MarshalAuthorizedKey(pub))+ice.SP+m.Option(TITLE),
|
||||
mdb.HashCreate(m, m.OptionSimple(TITLE), PUBLIC, string(ssh.MarshalAuthorizedKey(pub))+lex.SP+m.Option(TITLE),
|
||||
PRIVATE, string(pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)})),
|
||||
)
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ 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/nfs"
|
||||
psh "shylinux.com/x/icebergs/base/ssh"
|
||||
@ -184,7 +185,7 @@ func init() {
|
||||
list = append(list, fmt.Sprintf("%s %s %s", value[mdb.TYPE], value[mdb.TEXT], value[mdb.NAME]))
|
||||
})
|
||||
if len(list) > 0 {
|
||||
m.Cmdy(nfs.SAVE, kit.HomePath(m.Option(AUTHKEY)), strings.Join(list, ice.NL)+ice.NL)
|
||||
m.Cmdy(nfs.SAVE, kit.HomePath(m.Option(AUTHKEY)), strings.Join(list, lex.NL)+lex.NL)
|
||||
}
|
||||
}},
|
||||
aaa.INVITE: {Help: "邀请", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
psh "shylinux.com/x/icebergs/base/ssh"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -55,7 +56,7 @@ func init() {
|
||||
ctx.COMMAND: {Name: "command cmd=pwd", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.ZoneInsert(m, m.OptionSimple(mdb.HASH), mdb.TYPE, CMD, mdb.TEXT, m.Option(CMD))
|
||||
if w, ok := mdb.HashSelectTarget(m, m.Option(mdb.HASH), nil).(io.Writer); ok {
|
||||
w.Write([]byte(m.Option(CMD) + ice.NL))
|
||||
w.Write([]byte(m.Option(CMD) + lex.NL))
|
||||
m.Sleep300ms()
|
||||
}
|
||||
}},
|
||||
|
@ -7,7 +7,9 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"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/nfs"
|
||||
"shylinux.com/x/icebergs/base/ssh"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/code"
|
||||
@ -16,9 +18,9 @@ import (
|
||||
|
||||
func _tmux_key(arg ...string) string {
|
||||
if len(arg) > 2 {
|
||||
return arg[0] + ice.DF + arg[1] + ice.PT + arg[2]
|
||||
return arg[0] + nfs.DF + arg[1] + nfs.PT + arg[2]
|
||||
} else if len(arg) > 1 {
|
||||
return arg[0] + ice.DF + arg[1]
|
||||
return arg[0] + nfs.DF + arg[1]
|
||||
} else if len(arg) > 0 {
|
||||
return arg[0]
|
||||
} else {
|
||||
@ -181,23 +183,23 @@ func init() {
|
||||
} else if len(arg) > 0 {
|
||||
m.Cmdy(WINDOW, arg[0])
|
||||
} else {
|
||||
m.Split(_tmux_cmd(m, LIST_SESSION, "-F", mdb.Config(m, FORMAT)).Result(), mdb.Config(m, FIELDS), ice.FS, ice.NL)
|
||||
m.Split(_tmux_cmd(m, LIST_SESSION, "-F", mdb.Config(m, FORMAT)).Result(), mdb.Config(m, FIELDS), mdb.FS, lex.NL)
|
||||
}
|
||||
m.Table(func(value ice.Maps) {
|
||||
kit.If(value["tag"] == "1", func() { m.PushButton("") }, func() { m.PushButton(code.XTERM, mdb.SELECT, mdb.REMOVE) })
|
||||
}).StatusTimeCount()
|
||||
}},
|
||||
WINDOW: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Split(m.Cmdx(cli.SYSTEM, TMUX, LIST_WINDOWS, "-t", kit.Select("", arg, 0), "-F", mdb.Config(m, FORMAT)), mdb.Config(m, FIELDS), ice.FS, ice.NL)
|
||||
m.Split(m.Cmdx(cli.SYSTEM, TMUX, LIST_WINDOWS, "-t", kit.Select("", arg, 0), "-F", mdb.Config(m, FORMAT)), mdb.Config(m, FIELDS), mdb.FS, lex.NL)
|
||||
}},
|
||||
PANE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Split(_tmux_cmds(m, LIST_PANES, "-t", kit.Select("", arg, 0), "-F", mdb.Config(m, FORMAT)), mdb.Config(m, FIELDS), ice.FS, ice.NL)
|
||||
m.Split(_tmux_cmds(m, LIST_PANES, "-t", kit.Select("", arg, 0), "-F", mdb.Config(m, FORMAT)), mdb.Config(m, FIELDS), mdb.FS, lex.NL)
|
||||
}},
|
||||
VIEW: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(_tmux_cmds(m, CAPTURE_PANE, "-p", "-t", kit.Select("", arg, 0)))
|
||||
}},
|
||||
CMD: {Hand: func(m *ice.Message, arg ...string) {
|
||||
_tmux_cmd(m, SEND_KEYS, "-t", arg[0], strings.Join(arg[1:], ice.SP), ENTER)
|
||||
_tmux_cmd(m, SEND_KEYS, "-t", arg[0], strings.Join(arg[1:], lex.SP), ENTER)
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
@ -4,7 +4,9 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/misc/bash"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -20,10 +22,10 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
INPUT: {Name: "input hash auto export import", Help: "输入法", Actions: mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,hash,type,name,text")},
|
||||
web.P(INPUT): {Hand: func(m *ice.Message, arg ...string) {
|
||||
if arg[0] == ice.PT {
|
||||
if arg[0] == nfs.PT {
|
||||
|
||||
} else if strings.Contains(m.Option("pre"), "ice") {
|
||||
m.EchoLine(kit.Join(bash.Complete(m, true, kit.Split(strings.Split(m.Option("pre")+m.Option("cmds"), "ice")[1])...), ice.NL))
|
||||
m.EchoLine(kit.Join(bash.Complete(m, true, kit.Split(strings.Split(m.Option("pre")+m.Option("cmds"), "ice")[1])...), lex.NL))
|
||||
// mdb.HashCreate(m.Spawn(), kit.SimpleKV("", CMDS, strings.TrimSpace(arg[0]), m.Result()))
|
||||
} else if m.Cmdy(TAGS, INPUT, arg[0], m.Option("pre")); len(m.Result()) > 0 {
|
||||
// mdb.HashCreate(m, kit.SimpleKV("", TAGS, arg[0], m.Result()))
|
||||
|
@ -21,7 +21,7 @@ func init() {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(FAVOR, mdb.INPUTS, arg) }},
|
||||
code.INNER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
p := path.Join(m.Option(cli.PWD), m.Option(BUF))
|
||||
ctx.ProcessField(m, "", []string{path.Dir(p) + ice.PS, path.Base(p), m.Option(ROW)}, arg...)
|
||||
ctx.ProcessField(m, "", []string{path.Dir(p) + nfs.PS, path.Base(p), m.Option(ROW)}, arg...)
|
||||
}},
|
||||
FAVOR: {Name: "favor zone*=some type name text pwd buf row", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(FAVOR, mdb.INSERT, m.OptionSimple(mdb.ZONE, "type,name,text,pwd"), nfs.FILE, m.Option(BUF), nfs.LINE, m.Option(ROW))
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"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/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -22,20 +23,20 @@ func _tags_input(m *ice.Message, arg ...string) {
|
||||
if arg[1] == "" {
|
||||
kit.For([]string{"field", "shell", "refer", "section", "chapter", "title"}, func(k string) { kit.If(strings.HasPrefix(k, arg[0]), func() { m.EchoLine(k) }) })
|
||||
}
|
||||
m.EchoLine(kit.Join(bash.Complete(m, true, kit.Split(m.Option(PRE)+kit.Select("", ice.SP, !strings.HasSuffix(m.Option(PRE), ice.PT))+m.Option("cmds"))...), ice.SP+ice.NL))
|
||||
m.EchoLine(kit.Join(bash.Complete(m, true, kit.Split(m.Option(PRE)+kit.Select("", lex.SP, !strings.HasSuffix(m.Option(PRE), nfs.PT))+m.Option("cmds"))...), lex.SP+lex.NL))
|
||||
return
|
||||
}
|
||||
switch name := kit.Select("", kit.Slice(kit.Split(arg[1], "\t \n."), -1), 0); name {
|
||||
case "can", "sup", "sub":
|
||||
mdb.ZoneSelect(m).Table(func(value ice.Maps) {
|
||||
if strings.Contains(value[mdb.ZONE], arg[0]) || arg[0] == ice.PT {
|
||||
if strings.Contains(value[mdb.ZONE], arg[0]) || arg[0] == nfs.PT {
|
||||
m.EchoLine(value[mdb.ZONE])
|
||||
}
|
||||
})
|
||||
default:
|
||||
mdb.ZoneSelectCB(m.Echo("func").Echo(ice.NL), name, func(value ice.Maps) {
|
||||
if strings.Contains(value[mdb.NAME], arg[0]) || arg[0] == ice.PT {
|
||||
m.EchoLine(value[mdb.NAME]+kit.Select("", "(", value[mdb.TYPE] == "function")).EchoLine("%s: %s", value[mdb.NAME], strings.Split(value[mdb.TEXT], ice.NL)[0])
|
||||
mdb.ZoneSelectCB(m.Echo("func").Echo(lex.NL), name, func(value ice.Maps) {
|
||||
if strings.Contains(value[mdb.NAME], arg[0]) || arg[0] == nfs.PT {
|
||||
m.EchoLine(value[mdb.NAME]+kit.Select("", "(", value[mdb.TYPE] == "function")).EchoLine("%s: %s", value[mdb.NAME], strings.Split(value[mdb.TEXT], lex.NL)[0])
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -77,12 +78,12 @@ func init() {
|
||||
Qrcode(m, args[1])
|
||||
case wiki.FIELD:
|
||||
m.Search(kit.Select(args[1], args, 2), func(key string, cmd *ice.Command) {
|
||||
ls := kit.Split(cmd.FileLine(), ice.DF)
|
||||
ls := kit.Split(cmd.FileLine(), nfs.DF)
|
||||
m.Echo("vi +%s %s", ls[1], ls[0])
|
||||
})
|
||||
default:
|
||||
m.Search(args[0], func(key string, cmd *ice.Command) {
|
||||
ls := kit.Split(cmd.FileLine(), ice.DF)
|
||||
ls := kit.Split(cmd.FileLine(), nfs.DF)
|
||||
m.Echo("vi +%s %s", ls[1], ls[0])
|
||||
})
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
"shylinux.com/x/webview"
|
||||
@ -40,7 +41,7 @@ func (w WebView) Menu() bool {
|
||||
} else {
|
||||
w.WebView.SetTitle(ice.CONTEXTS)
|
||||
w.WebView.SetSize(200, 60*len(list), webview.HintNone)
|
||||
w.WebView.Navigate(kit.Format(`data:text/html,`+ice.Pulse.Cmdx(nfs.CAT, path.Join(ice.SRC_TEMPLATE, "webview", "home.html")), kit.Join(list, ice.NL)))
|
||||
w.WebView.Navigate(kit.Format(`data:text/html,`+ice.Pulse.Cmdx(nfs.CAT, path.Join(ice.SRC_TEMPLATE, "webview", "home.html")), kit.Join(list, lex.NL)))
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -58,7 +59,7 @@ func (w WebView) SetSize(width, height int) {
|
||||
}
|
||||
func (w WebView) System(arg ...string) string { return w.Cmdx(cli.SYSTEM, arg) }
|
||||
func (w WebView) Power() string {
|
||||
ls := strings.Split(w.Cmdx(cli.SYSTEM, "pmset", "-g", "ps"), ice.NL)
|
||||
ls := strings.Split(w.Cmdx(cli.SYSTEM, "pmset", "-g", "ps"), lex.NL)
|
||||
for _, line := range ls[1:] {
|
||||
ls := kit.Split(line, "\t ;", "\t ;")
|
||||
return ls[2]
|
||||
|
@ -5,6 +5,7 @@ package xterm
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
@ -25,3 +26,6 @@ func ioctl(fd, cmd, ptr uintptr) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func Setsid(cmd *exec.Cmd) {
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true, Setctty: true}
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package pty
|
||||
package xterm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func Setsid(cmd *exec.Cmd) {}
|
||||
func Setsize(*os.File, *Winsize) error { return errors.New("unsupported") }
|
||||
func Open() (pty, tty *os.File, err error) { return nil, nil, errors.New("unsuported") }
|
||||
func Open() (pty, tty *os.File, err error) { return nil, nil, errors.New("unsupported") }
|
||||
|
@ -3,9 +3,9 @@ package xterm
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
@ -26,7 +26,7 @@ func (s XTerm) Setsize(rows, cols string) error {
|
||||
return Setsize(s.File, &Winsize{Rows: uint16(kit.Int(rows)), Cols: uint16(kit.Int(cols))})
|
||||
}
|
||||
func (s XTerm) Writeln(data string, arg ...ice.Any) {
|
||||
s.Write(kit.Format(data, arg...) + ice.NL)
|
||||
s.Write(kit.Format(data, arg...) + lex.NL)
|
||||
}
|
||||
func (s XTerm) Write(data string) (int, error) {
|
||||
return s.File.Write([]byte(data))
|
||||
@ -39,11 +39,11 @@ func Command(m *ice.Message, dir string, cli string, arg ...string) (*XTerm, err
|
||||
cmd.Dir = nfs.MkdirAll(m, kit.Path(dir))
|
||||
cmd.Env = append(cmd.Env, os.Environ()...)
|
||||
cmd.Env = append(cmd.Env, "TERM=xterm")
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true, Setctty: true}
|
||||
pty, tty, err := Open()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cmd.Stdin, cmd.Stdout, cmd.Stderr = tty, tty, tty
|
||||
Setsid(cmd)
|
||||
return &XTerm{cmd, pty}, cmd.Start()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user