mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 17:44:05 +08:00
add some
This commit is contained in:
parent
d61d524b89
commit
a86ca7b2d0
@ -43,7 +43,7 @@ var _release = ""
|
|||||||
|
|
||||||
func release(m *ice.Message) string {
|
func release(m *ice.Message) string {
|
||||||
osid := runtime.GOOS
|
osid := runtime.GOOS
|
||||||
if osid != LINUX {
|
if osid != LINUX || !nfs.Exists(m, "/etc/os-release") {
|
||||||
return osid
|
return osid
|
||||||
}
|
}
|
||||||
m.Option(nfs.CAT_CONTENT, _release)
|
m.Option(nfs.CAT_CONTENT, _release)
|
||||||
|
29
base/cli/procinfo.go
Normal file
29
base/cli/procinfo.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/gdb"
|
||||||
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
|
kit "shylinux.com/x/toolkits"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Index.MergeCommands(ice.Commands{
|
||||||
|
PROCINFO: {Name: "procinfo PID auto", Help: "进程列表", Actions: ice.MergeActions(ice.Actions{
|
||||||
|
PROCKILL: {Help: "结束进程", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(gdb.SIGNAL, gdb.STOP, m.Option("PID")).ProcessRefresh() }},
|
||||||
|
}), Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if len(arg) == 0 {
|
||||||
|
m.Split(m.Cmdx(SYSTEM, "ps", "u")).PushAction(PROCKILL).Sort("COMMAND").StatusTimeCount(m.Cmd(RUNTIME, HOSTINFO).AppendSimple("nCPU,MemTotal,MemFree"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.OptionFields(mdb.DETAIL)
|
||||||
|
for _, line := range kit.SplitLine(m.Cmdx(nfs.CAT, kit.Format("/proc/%s/status", arg[0]))) {
|
||||||
|
ls := strings.SplitN(line, nfs.DF, 2)
|
||||||
|
m.Push(ls[0], ls[1])
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
})
|
||||||
|
}
|
@ -1,13 +1,13 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/aaa"
|
"shylinux.com/x/icebergs/base/aaa"
|
||||||
|
"shylinux.com/x/icebergs/base/gdb"
|
||||||
"shylinux.com/x/icebergs/base/lex"
|
"shylinux.com/x/icebergs/base/lex"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
@ -35,13 +35,11 @@ func newprocstat(m *ice.Message) (stat procstat) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Option(ice.MSG_USERROLE, aaa.ROOT)
|
m.Option(ice.MSG_USERROLE, aaa.ROOT)
|
||||||
if ls := kit.Split(m.Cmdx(nfs.CAT, kit.Format("/proc/%d/stat", os.Getpid())), " ()"); len(ls) > 0 {
|
if ls := kit.Split(m.Cmdx(nfs.CAT, "/proc/self/stat"), " ()"); len(ls) > 0 {
|
||||||
stat = procstat{utime: kit.Int64(ls[13]), stime: kit.Int64(ls[14]), vmsize: kit.Int64(ls[22]), vmrss: kit.Int64(ls[23]) * 4096}
|
stat = procstat{utime: kit.Int64(ls[13]), stime: kit.Int64(ls[14]), vmsize: kit.Int64(ls[22]), vmrss: kit.Int64(ls[23]) * 4096}
|
||||||
}
|
}
|
||||||
if ls := kit.Split(kit.Select("", strings.Split(m.Cmdx(nfs.CAT, "/proc/stat"), lex.NL), 1)); len(ls) > 0 {
|
if ls := kit.Split(kit.Select("", strings.Split(m.Cmdx(nfs.CAT, "/proc/stat"), lex.NL), 1)); len(ls) > 0 {
|
||||||
stat.user = kit.Int64(ls[1])
|
stat.user, stat.sys, stat.idle = kit.Int64(ls[1]), kit.Int64(ls[3]), kit.Int64(ls[4])
|
||||||
stat.sys = kit.Int64(ls[3])
|
|
||||||
stat.idle = kit.Int64(ls[4])
|
|
||||||
}
|
}
|
||||||
for _, line := range strings.Split(strings.TrimSpace(m.Cmdx(nfs.CAT, "/proc/meminfo")), lex.NL) {
|
for _, line := range strings.Split(strings.TrimSpace(m.Cmdx(nfs.CAT, "/proc/meminfo")), lex.NL) {
|
||||||
switch ls := kit.Split(line, ": "); ls[0] {
|
switch ls := kit.Split(line, ": "); ls[0] {
|
||||||
@ -71,9 +69,14 @@ func newprocstat(m *ice.Message) (stat procstat) {
|
|||||||
func init() {
|
func init() {
|
||||||
var last procstat
|
var last procstat
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
"procstat": {Name: "procstat id list page", Actions: ice.MergeActions(ice.Actions{
|
PROCSTAT: {Name: "procstat id list page start", Help: "进程统计", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { last = newprocstat(m) }},
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { last = newprocstat(m) }},
|
||||||
mdb.INSERT: {Name: "insert", Hand: func(m *ice.Message, arg ...string) {
|
START: {Name: "start interval*=10s least*=360 limit*=720", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmd(gdb.TIMER, mdb.CREATE, mdb.NAME, m.CommandKey(), gdb.DELAY, "1s", m.OptionSimple(gdb.INTERVAL), mdb.COUNT, "-1", ice.CMD, "cli.procstat insert")
|
||||||
|
mdb.Config(m, mdb.LEAST, m.Option(mdb.LEAST))
|
||||||
|
mdb.Config(m, mdb.LIMIT, m.Option(mdb.LIMIT))
|
||||||
|
}},
|
||||||
|
mdb.INSERT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
stat := newprocstat(m)
|
stat := newprocstat(m)
|
||||||
total := stat.user - last.user + stat.sys - last.sys + stat.idle - last.idle
|
total := stat.user - last.user + stat.sys - last.sys + stat.idle - last.idle
|
||||||
m.Cmd(mdb.INSERT, m.PrefixKey(), "", mdb.LIST,
|
m.Cmd(mdb.INSERT, m.PrefixKey(), "", mdb.LIST,
|
||||||
@ -83,8 +86,8 @@ func init() {
|
|||||||
)
|
)
|
||||||
last = stat
|
last = stat
|
||||||
}},
|
}},
|
||||||
}, mdb.PageListAction(mdb.LIMIT, "720", mdb.LEAST, "360", mdb.FIELD, "time,id,utime,vmrss,user,idle,free,rx,tx,established,time_wait")), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.PageListAction(mdb.FIELD, "time,id,utime,vmrss,user,idle,free,rx,tx,established,time_wait")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.OptionDefault(mdb.CACHE_LIMIT, "360")
|
m.OptionDefault(mdb.CACHE_LIMIT, mdb.Config(m, mdb.LEAST))
|
||||||
if mdb.PageListSelect(m, arg...); (len(arg) == 0 || arg[0] == "") && m.Length() > 0 {
|
if mdb.PageListSelect(m, arg...); (len(arg) == 0 || arg[0] == "") && m.Length() > 0 {
|
||||||
m.SortInt(mdb.ID).Display("/plugin/story/trend.js", ice.VIEW, "折线图", "min", "0", "max", "1000", COLOR, "yellow,cyan,red,green,blue,purple,purple")
|
m.SortInt(mdb.ID).Display("/plugin/story/trend.js", ice.VIEW, "折线图", "min", "0", "max", "1000", COLOR, "yellow,cyan,red,green,blue,purple,purple")
|
||||||
m.Status("from", m.Append(mdb.TIME), "span", kit.FmtDuration(time.Duration(kit.Time(m.Time())-kit.Time(m.Append(mdb.TIME)))), m.AppendSimple(mdb.Config(m, mdb.FIELD)), "cursor", "0")
|
m.Status("from", m.Append(mdb.TIME), "span", kit.FmtDuration(time.Duration(kit.Time(m.Time())-kit.Time(m.Append(mdb.TIME)))), m.AppendSimple(mdb.Config(m, mdb.FIELD)), "cursor", "0")
|
||||||
|
@ -135,6 +135,7 @@ const (
|
|||||||
DISKINFO = "diskinfo"
|
DISKINFO = "diskinfo"
|
||||||
HOSTINFO = "hostinfo"
|
HOSTINFO = "hostinfo"
|
||||||
USERINFO = "userinfo"
|
USERINFO = "userinfo"
|
||||||
|
PROCSTAT = "procstat"
|
||||||
PROCINFO = "procinfo"
|
PROCINFO = "procinfo"
|
||||||
PROCKILL = "prockill"
|
PROCKILL = "prockill"
|
||||||
BOOTINFO = "bootinfo"
|
BOOTINFO = "bootinfo"
|
||||||
@ -144,7 +145,7 @@ const RUNTIME = "runtime"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
RUNTIME: {Name: "runtime info=bootinfo,ifconfig,diskinfo,hostinfo,userinfo,procinfo,bootinfo,api,cli,cmd,mod,env,path,chain,routine auto", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{
|
RUNTIME: {Name: "runtime info=bootinfo,ifconfig,diskinfo,hostinfo,userinfo,procstat,procinfo,bootinfo,api,cli,cmd,mod,env,path,chain,routine auto", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _runtime_init(m) }},
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _runtime_init(m) }},
|
||||||
IFCONFIG: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("tcp.host") }},
|
IFCONFIG: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("tcp.host") }},
|
||||||
DISKINFO: {Hand: func(m *ice.Message, arg ...string) { _runtime_diskinfo(m) }},
|
DISKINFO: {Hand: func(m *ice.Message, arg ...string) { _runtime_diskinfo(m) }},
|
||||||
@ -156,11 +157,8 @@ func init() {
|
|||||||
m.Echo(ice.Info.Hostname)
|
m.Echo(ice.Info.Hostname)
|
||||||
}},
|
}},
|
||||||
USERINFO: {Hand: func(m *ice.Message, arg ...string) { m.Split(m.Cmdx(SYSTEM, "who"), "user term time") }},
|
USERINFO: {Hand: func(m *ice.Message, arg ...string) { m.Split(m.Cmdx(SYSTEM, "who"), "user term time") }},
|
||||||
PROCINFO: {Hand: func(m *ice.Message, arg ...string) {
|
PROCSTAT: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(PROCSTAT) }},
|
||||||
msg := m.Cmd("", HOSTINFO)
|
PROCINFO: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(PROCINFO) }},
|
||||||
m.Split(m.Cmdx(SYSTEM, "ps", "u")).PushAction(PROCKILL).Sort("COMMAND")
|
|
||||||
m.StatusTimeCount("nCPU", msg.Append("nCPU"), "MemTotal", msg.Append("MemTotal"), "MemFree", msg.Append("MemFree"))
|
|
||||||
}},
|
|
||||||
PROCKILL: {Help: "结束进程", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(gdb.SIGNAL, gdb.STOP, m.Option("PID")).ProcessRefresh() }},
|
PROCKILL: {Help: "结束进程", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(gdb.SIGNAL, gdb.STOP, m.Option("PID")).ProcessRefresh() }},
|
||||||
MAXPROCS: {Hand: func(m *ice.Message, arg ...string) {
|
MAXPROCS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
kit.If(len(arg) > 0, func() { runtime.GOMAXPROCS(kit.Int(mdb.Conf(m, RUNTIME, kit.Keys(HOST, MAXPROCS), arg[0]))) })
|
kit.If(len(arg) > 0, func() { runtime.GOMAXPROCS(kit.Int(mdb.Conf(m, RUNTIME, kit.Keys(HOST, MAXPROCS), arg[0]))) })
|
||||||
|
@ -34,6 +34,14 @@ func init() {
|
|||||||
TIMER: {Name: "timer name auto create prunes", Help: "定时器", Actions: ice.MergeActions(ice.Actions{
|
TIMER: {Name: "timer name auto create prunes", Help: "定时器", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.CREATE: {Name: "create name*=hi delay=10ms interval=10s count=3 cmd*=runtime"},
|
mdb.CREATE: {Name: "create name*=hi delay=10ms interval=10s count=3 cmd*=runtime"},
|
||||||
mdb.PRUNES: {Hand: func(m *ice.Message, arg ...string) { mdb.HashPrunesValue(m, mdb.COUNT, "0") }},
|
mdb.PRUNES: {Hand: func(m *ice.Message, arg ...string) { mdb.HashPrunesValue(m, mdb.COUNT, "0") }},
|
||||||
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
switch mdb.HashInputs(m, arg); arg[0] {
|
||||||
|
case "count":
|
||||||
|
m.Push(arg[0], "-1")
|
||||||
|
case "cmd":
|
||||||
|
m.Push(arg[0], "cli.procstat insert")
|
||||||
|
}
|
||||||
|
}},
|
||||||
HAPPEN: {Hand: func(m *ice.Message, arg ...string) { _timer_action(m, time.Now(), arg...) }},
|
HAPPEN: {Hand: func(m *ice.Message, arg ...string) { _timer_action(m, time.Now(), arg...) }},
|
||||||
RESTART: {Name: "restart count=3", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, m.OptionSimple(mdb.HashShort(m)), arg) }},
|
RESTART: {Name: "restart count=3", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, m.OptionSimple(mdb.HashShort(m)), arg) }},
|
||||||
}, mdb.HashAction(mdb.SHORT, "name", mdb.FIELD, "time,hash,name,delay,interval,count,cmd", TICK, "1s"))},
|
}, mdb.HashAction(mdb.SHORT, "name", mdb.FIELD, "time,hash,name,delay,interval,count,cmd", TICK, "1s"))},
|
||||||
|
@ -3,6 +3,7 @@ package mdb
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -105,7 +106,10 @@ func _hash_export(m *ice.Message, prefix, chain, file string) {
|
|||||||
}
|
}
|
||||||
func _hash_import(m *ice.Message, prefix, chain, file string) {
|
func _hash_import(m *ice.Message, prefix, chain, file string) {
|
||||||
defer Lock(m, prefix, chain)()
|
defer Lock(m, prefix, chain)()
|
||||||
f, e := miss.OpenFile(kit.Keys(file, JSON))
|
f, e := ice.Info.OpenFile(m, kit.Keys(file, JSON))
|
||||||
|
if os.IsNotExist(e) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if m.Warn(e) {
|
if m.Warn(e) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -113,8 +117,9 @@ func _hash_import(m *ice.Message, prefix, chain, file string) {
|
|||||||
data := Map{}
|
data := Map{}
|
||||||
m.Assert(json.NewDecoder(f).Decode(&data))
|
m.Assert(json.NewDecoder(f).Decode(&data))
|
||||||
m.Logs(IMPORT, KEY, path.Join(prefix, chain), FILE, kit.Keys(file, JSON), COUNT, len(data))
|
m.Logs(IMPORT, KEY, path.Join(prefix, chain), FILE, kit.Keys(file, JSON), COUNT, len(data))
|
||||||
defer m.Echo("%d", len(data))
|
kit.If(m.Confv(prefix, kit.Keys(chain, HASH)) == nil, func() { m.Confv(prefix, kit.Keys(chain, HASH), ice.Map{}) })
|
||||||
kit.For(data, func(k string, v Any) { m.Confv(prefix, kit.Keys(chain, HASH, k), v) })
|
kit.For(data, func(k string, v Any) { m.Confv(prefix, kit.Keys(chain, HASH, k), v) })
|
||||||
|
m.Echo("%d", len(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -255,9 +255,7 @@ func AutoConfig(arg ...Any) *ice.Action {
|
|||||||
}
|
}
|
||||||
func ImportantZoneAction(arg ...Any) ice.Actions {
|
func ImportantZoneAction(arg ...Any) ice.Actions {
|
||||||
return ice.MergeActions(ice.Actions{
|
return ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { Config(m, "important", ice.TRUE) }},
|
||||||
Config(m, "important", ice.TRUE)
|
|
||||||
}},
|
|
||||||
}, ZoneAction(arg...))
|
}, ZoneAction(arg...))
|
||||||
}
|
}
|
||||||
func ImportantHashAction(arg ...Any) ice.Actions {
|
func ImportantHashAction(arg ...Any) ice.Actions {
|
||||||
|
@ -94,7 +94,10 @@ func _zone_export(m *ice.Message, prefix, chain, file string) {
|
|||||||
}
|
}
|
||||||
func _zone_import(m *ice.Message, prefix, chain, file string) {
|
func _zone_import(m *ice.Message, prefix, chain, file string) {
|
||||||
defer Lock(m, prefix, chain)()
|
defer Lock(m, prefix, chain)()
|
||||||
f, e := miss.OpenFile(kit.Keys(file, CSV))
|
f, e := ice.Info.OpenFile(m, kit.Keys(file, CSV))
|
||||||
|
if os.IsNotExist(e) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if m.Warn(e) {
|
if m.Warn(e) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,10 @@ func _cat_find(m *ice.Message, p string) (io.ReadCloser, error) {
|
|||||||
return OpenFile(m, path.Join(m.Option(DIR_ROOT), p))
|
return OpenFile(m, path.Join(m.Option(DIR_ROOT), p))
|
||||||
}
|
}
|
||||||
func _cat_hash(m *ice.Message, p string) (h string) {
|
func _cat_hash(m *ice.Message, p string) (h string) {
|
||||||
Open(m, p, func(r io.Reader) { h = kit.Hashs(r) })
|
Open(m, p, func(r io.Reader) {
|
||||||
|
h = kit.Hashs(r)
|
||||||
|
m.Debug("what %v %v", p, h)
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func _cat_line(m *ice.Message, p string) (n int) {
|
func _cat_line(m *ice.Message, p string) (n int) {
|
||||||
|
@ -58,6 +58,7 @@ var PackFile = file.NewPackFile()
|
|||||||
var DiskFile = file.NewDiskFile()
|
var DiskFile = file.NewDiskFile()
|
||||||
|
|
||||||
func init() { file.Init(OptionFiles(ice.Pulse, DiskFile, PackFile)) }
|
func init() { file.Init(OptionFiles(ice.Pulse, DiskFile, PackFile)) }
|
||||||
|
func init() { ice.Info.OpenFile = OpenFile }
|
||||||
|
|
||||||
type optionMessage interface {
|
type optionMessage interface {
|
||||||
Optionv(key string, arg ...ice.Any) ice.Any
|
Optionv(key string, arg ...ice.Any) ice.Any
|
||||||
@ -72,7 +73,7 @@ func OptionFiles(m optionMessage, f ...file.File) file.File {
|
|||||||
return m.Optionv(ice.MSG_FILES).(file.File)
|
return m.Optionv(ice.MSG_FILES).(file.File)
|
||||||
}
|
}
|
||||||
func StatFile(m optionMessage, p string) (os.FileInfo, error) { return OptionFiles(m).StatFile(p) }
|
func StatFile(m optionMessage, p string) (os.FileInfo, error) { return OptionFiles(m).StatFile(p) }
|
||||||
func OpenFile(m optionMessage, p string) (io.ReadCloser, error) { return OptionFiles(m).OpenFile(p) }
|
func OpenFile(m *ice.Message, p string) (io.ReadCloser, error) { return OptionFiles(m).OpenFile(p) }
|
||||||
func CreateFile(m optionMessage, p string) (io.WriteCloser, string, error) {
|
func CreateFile(m optionMessage, p string) (io.WriteCloser, string, error) {
|
||||||
return OptionFiles(m).CreateFile(p)
|
return OptionFiles(m).CreateFile(p)
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,13 @@ func (f *Frame) scan(m *ice.Message, h, line string) *Frame {
|
|||||||
if len(bio.Text()) == 0 && h == STDIO {
|
if len(bio.Text()) == 0 && h == STDIO {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if f.count++; len(bio.Text()) == 0 {
|
f.count++
|
||||||
|
if line += bio.Text(); strings.Count(line, "`")%2 == 1 {
|
||||||
|
line += lex.NL
|
||||||
|
ps = f.ps2
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(bio.Text()) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(bio.Text(), "\\") {
|
if strings.HasSuffix(bio.Text(), "\\") {
|
||||||
@ -119,11 +125,6 @@ func (f *Frame) scan(m *ice.Message, h, line string) *Frame {
|
|||||||
ps = f.ps2
|
ps = f.ps2
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if line += bio.Text(); strings.Count(line, "`")%2 == 1 {
|
|
||||||
line += lex.NL
|
|
||||||
ps = f.ps2
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(strings.TrimSpace(line), "#") {
|
if strings.HasPrefix(strings.TrimSpace(line), "#") {
|
||||||
line = ""
|
line = ""
|
||||||
continue
|
continue
|
||||||
|
@ -26,8 +26,8 @@ func _broad_serve(m *ice.Message) {
|
|||||||
})
|
})
|
||||||
m.Cmd(tcp.SERVER, tcp.LISTEN, mdb.TYPE, tcp.UDP4, mdb.NAME, logs.FileLine(1), m.OptionSimple(tcp.HOST, tcp.PORT), func(from *net.UDPAddr, buf []byte) {
|
m.Cmd(tcp.SERVER, tcp.LISTEN, mdb.TYPE, tcp.UDP4, mdb.NAME, logs.FileLine(1), m.OptionSimple(tcp.HOST, tcp.PORT), func(from *net.UDPAddr, buf []byte) {
|
||||||
msg := m.Spawn(buf).Logs(tcp.RECV, BROAD, string(buf), nfs.FROM, from)
|
msg := m.Spawn(buf).Logs(tcp.RECV, BROAD, string(buf), nfs.FROM, from)
|
||||||
if mdb.HashCreate(m, msg.OptionSimple(kit.Simple(msg.Optionv(ice.MSG_OPTION))...)); msg.Option(gdb.EVENT) == tcp.LISTEN {
|
if m.Cmd(BROAD, mdb.CREATE, msg.OptionSimple(kit.Simple(msg.Optionv(ice.MSG_OPTION))...)); msg.Option(gdb.EVENT) == tcp.LISTEN {
|
||||||
m.Cmds("", func(value ice.Maps) {
|
m.Cmds(BROAD, func(value ice.Maps) {
|
||||||
_broad_send(m, msg.Option(tcp.HOST), msg.Option(tcp.PORT), value[tcp.HOST], value[tcp.PORT], mdb.TYPE, value[mdb.TYPE], mdb.NAME, value[mdb.NAME])
|
_broad_send(m, msg.Option(tcp.HOST), msg.Option(tcp.PORT), value[tcp.HOST], value[tcp.PORT], mdb.TYPE, value[mdb.TYPE], mdb.NAME, value[mdb.NAME])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -52,9 +52,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
SERVE_START: {Hand: func(m *ice.Message, arg ...string) {
|
SERVE_START: {Hand: func(m *ice.Message, arg ...string) { gdb.Go(m, _broad_serve) }},
|
||||||
gdb.Go(m, _broad_serve)
|
|
||||||
}},
|
|
||||||
SERVE: {Name: "serve port=9020 host", Hand: func(m *ice.Message, arg ...string) { gdb.Go(m, _broad_serve) }},
|
SERVE: {Name: "serve port=9020 host", Hand: func(m *ice.Message, arg ...string) { gdb.Go(m, _broad_serve) }},
|
||||||
OPEN: {Hand: func(m *ice.Message, arg ...string) {
|
OPEN: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
ctx.ProcessOpen(m, Domain(m.Option(tcp.HOST), m.Option(tcp.PORT)))
|
ctx.ProcessOpen(m, Domain(m.Option(tcp.HOST), m.Option(tcp.PORT)))
|
||||||
|
@ -60,10 +60,10 @@ func _dream_start(m *ice.Message, name string) {
|
|||||||
}
|
}
|
||||||
defer ToastProcess(m)()
|
defer ToastProcess(m)()
|
||||||
defer m.Sleep("1s")
|
defer m.Sleep("1s")
|
||||||
m.Options(cli.CMD_DIR, kit.Path(p), cli.CMD_ENV, kit.Simple(
|
m.Options(cli.CMD_DIR, kit.Path(p), cli.CMD_ENV, kit.EnvList(kit.Simple(
|
||||||
cli.CTX_OPS, Domain(tcp.LOCALHOST, m.Cmdv(SERVE, tcp.PORT)), cli.CTX_LOG, ice.VAR_LOG_BOOT_LOG, cli.CTX_PID, ice.VAR_LOG_ICE_PID,
|
cli.CTX_OPS, Domain(tcp.LOCALHOST, m.Cmdv(SERVE, tcp.PORT)), cli.CTX_LOG, ice.VAR_LOG_BOOT_LOG, cli.CTX_PID, ice.VAR_LOG_ICE_PID,
|
||||||
cli.PATH, cli.BinPath(p, ""), cli.USER, ice.Info.Username, kit.EnvSimple(cli.HOME, cli.TERM, cli.SHELL, "USERPROFILE"), mdb.Configv(m, cli.ENV),
|
cli.PATH, cli.BinPath(p, ""), cli.USER, ice.Info.Username,
|
||||||
), cli.CMD_OUTPUT, path.Join(p, ice.VAR_LOG_BOOT_LOG), mdb.CACHE_CLEAR_ONEXIT, ice.TRUE)
|
)...), cli.CMD_OUTPUT, path.Join(p, ice.VAR_LOG_BOOT_LOG), mdb.CACHE_CLEAR_ONEXIT, ice.TRUE)
|
||||||
defer m.Options(cli.CMD_DIR, "", cli.CMD_ENV, "", cli.CMD_OUTPUT, "")
|
defer m.Options(cli.CMD_DIR, "", cli.CMD_ENV, "", cli.CMD_OUTPUT, "")
|
||||||
gdb.Event(m, DREAM_CREATE, m.OptionSimple(mdb.NAME, mdb.TYPE))
|
gdb.Event(m, DREAM_CREATE, m.OptionSimple(mdb.NAME, mdb.TYPE))
|
||||||
kit.If(m.Option(nfs.BINARY), func(p string) { _dream_binary(m, p) })
|
kit.If(m.Option(nfs.BINARY), func(p string) { _dream_binary(m, p) })
|
||||||
|
@ -35,6 +35,8 @@ const FAVOR = "favor"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
FAVOR: {Name: "favor hash auto create upload getClipboardData", Help: "收藏夹", Actions: ice.MergeActions(ice.Actions{
|
FAVOR: {Name: "favor hash auto create upload getClipboardData", Help: "收藏夹", Actions: ice.MergeActions(ice.Actions{
|
||||||
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashImport(m) }},
|
||||||
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashExport(m) }},
|
||||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if arg[0] == mdb.FOREACH {
|
if arg[0] == mdb.FOREACH {
|
||||||
m.Cmd("", ice.OptionFields("")).Table(func(value ice.Maps) {
|
m.Cmd("", ice.OptionFields("")).Table(func(value ice.Maps) {
|
||||||
|
@ -20,12 +20,11 @@ func _binpack_file(m *ice.Message, w io.Writer, arg ...string) {
|
|||||||
if strings.HasPrefix(arg[0], "usr/volcanos/publish/") && !strings.HasSuffix(arg[0], "/proto.js") {
|
if strings.HasPrefix(arg[0], "usr/volcanos/publish/") && !strings.HasSuffix(arg[0], "/proto.js") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(arg[0], "usr/volcanos/page/") && !strings.Contains(arg[0], "/cache.") {
|
|
||||||
fmt.Fprintf(w, " \"%s\": \"%s\",\n", kit.Select(arg[0], arg, 1), "")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case ice.SRC_VERSION_GO, ice.SRC_BINPACK_GO, ice.ETC_LOCAL_SHY:
|
case ice.SRC_VERSION_GO, ice.SRC_BINPACK_GO:
|
||||||
|
return
|
||||||
|
case ice.ETC_LOCAL_SHY:
|
||||||
|
fmt.Fprintf(w, " \"%s\": \"%s\",\n", kit.Select(arg[0], arg, 1), "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if f, e := nfs.OpenFile(m, arg[0]); !m.Warn(e, ice.ErrNotFound, arg[0]) {
|
if f, e := nfs.OpenFile(m, arg[0]); !m.Warn(e, ice.ErrNotFound, arg[0]) {
|
||||||
@ -49,18 +48,10 @@ func _binpack_all(m *ice.Message) {
|
|||||||
for _, p := range []string{ice.USR_VOLCANOS, ice.USR_INTSHELL, ice.SRC} {
|
for _, p := range []string{ice.USR_VOLCANOS, ice.USR_INTSHELL, ice.SRC} {
|
||||||
_binpack_dir(m, w, p)
|
_binpack_dir(m, w, p)
|
||||||
}
|
}
|
||||||
for _, p := range []string{ice.ETC_MISS_SH, ice.ETC_INIT_SHY, ice.ETC_EXIT_SHY, ice.README_MD, ice.MAKEFILE, ice.LICENSE} {
|
for _, p := range []string{ice.ETC_MISS_SH, ice.ETC_INIT_SHY, ice.ETC_LOCAL_SHY, ice.ETC_EXIT_SHY, ice.ETC_PATH, ice.README_MD, ice.MAKEFILE, ice.LICENSE} {
|
||||||
_binpack_file(m, w, p)
|
_binpack_file(m, w, p)
|
||||||
}
|
}
|
||||||
list, cache := map[string]string{}, kit.GetValid(
|
list, cache := map[string]string{}, GoCache(m)
|
||||||
func() string { return m.Cmdx(cli.SYSTEM, GO, "env", "GOMODCACHE") },
|
|
||||||
func() string {
|
|
||||||
return kit.Select(kit.HomePath("go")+nfs.PS, m.Cmdx(cli.SYSTEM, GO, "env", "GOPATH")) + "/pkg/mod/"
|
|
||||||
},
|
|
||||||
func() string {
|
|
||||||
return ice.USR_REQUIRE
|
|
||||||
},
|
|
||||||
)
|
|
||||||
for k := range ice.Info.File {
|
for k := range ice.Info.File {
|
||||||
switch ls := kit.Split(k, nfs.PS); ls[1] {
|
switch ls := kit.Split(k, nfs.PS); ls[1] {
|
||||||
case ice.SRC:
|
case ice.SRC:
|
||||||
@ -99,3 +90,12 @@ func init() {
|
|||||||
}, mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path"))},
|
}, mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path"))},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
func GoCache(m *ice.Message) string {
|
||||||
|
return kit.GetValid(
|
||||||
|
func() string { return m.Cmdx(cli.SYSTEM, GO, "env", "GOMODCACHE") },
|
||||||
|
func() string {
|
||||||
|
return kit.Select(kit.HomePath("go")+nfs.PS, m.Cmdx(cli.SYSTEM, GO, "env", "GOPATH")) + "/pkg/mod/"
|
||||||
|
},
|
||||||
|
func() string { return ice.USR_REQUIRE },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@ -48,7 +48,7 @@ func _publish_contexts(m *ice.Message, arg ...string) {
|
|||||||
case ice.CORE:
|
case ice.CORE:
|
||||||
m.Option(web.DOMAIN, m.Cmd(web.SPIDE, ice.DEV).Append(web.CLIENT_ORIGIN))
|
m.Option(web.DOMAIN, m.Cmd(web.SPIDE, ice.DEV).Append(web.CLIENT_ORIGIN))
|
||||||
default:
|
default:
|
||||||
_publish_file(m, ice.ICE_BIN)
|
// _publish_file(m, ice.ICE_BIN)
|
||||||
}
|
}
|
||||||
m.EchoScript(strings.TrimSpace(nfs.Template(m, kit.Keys(k, SH))))
|
m.EchoScript(strings.TrimSpace(nfs.Template(m, kit.Keys(k, SH))))
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ const PLAN = "plan"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
PLAN: {Name: "plan scale=week,day,week,month,year,long begin_time@date list prev next", Help: "任务计划", Actions: ice.MergeActions(ice.Actions{
|
PLAN: {Name: "plan scale=week,day,week,month,year,long begin_time@date list prev next", Help: "计划表", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TODO, mdb.INPUTS, arg) }},
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TODO, mdb.INPUTS, arg) }},
|
||||||
mdb.PLUGIN: {Name: "plugin extra.index extra.args", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.MODIFY, arg) }},
|
mdb.PLUGIN: {Name: "plugin extra.index extra.args", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.MODIFY, arg) }},
|
||||||
mdb.INSERT: {Name: "insert zone* type=once,step,week name* text begin_time@date close_time@date", Hand: func(m *ice.Message, arg ...string) {
|
mdb.INSERT: {Name: "insert zone* type=once,step,week name* text begin_time@date close_time@date", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/lex"
|
"shylinux.com/x/icebergs/base/lex"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
@ -16,7 +17,7 @@ const DATA = "data"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
DATA: {Name: "data path type@key field auto create push save draw", Help: "数据表格", Actions: ice.MergeActions(ice.Actions{
|
DATA: {Name: "data path type@key field auto", Help: "数据表格", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case mdb.TYPE:
|
case mdb.TYPE:
|
||||||
@ -29,8 +30,15 @@ func init() {
|
|||||||
nfs.PUSH: {Name: "push path record", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
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:], mdb.FS)+lex.NL)
|
m.Cmd(nfs.PUSH, path.Join(mdb.Config(m, nfs.PATH), arg[0]), kit.Join(arg[1:], mdb.FS)+lex.NL)
|
||||||
}}, "draw": {Help: "绘图"},
|
}}, "draw": {Help: "绘图"},
|
||||||
}, WikiAction(ice.USR_LOCAL_EXPORT, nfs.CSV)), Hand: func(m *ice.Message, arg ...string) {
|
}, WikiAction(ice.USR_LOCAL_EXPORT, nfs.CSV, nfs.JSON)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
kit.If(!_wiki_list(m, arg...), func() { CSV(m, m.Cmdx(nfs.CAT, arg[0])).StatusTimeCount() })
|
kit.If(!_wiki_list(m, arg...), func() {
|
||||||
|
if kit.Ext(arg[0]) == nfs.JSON {
|
||||||
|
m.Cmdy(nfs.CAT, arg[0])
|
||||||
|
ctx.DisplayStoryJSON(m)
|
||||||
|
} else {
|
||||||
|
CSV(m, m.Cmdx(nfs.CAT, arg[0])).StatusTimeCount()
|
||||||
|
}
|
||||||
|
})
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package wiki
|
package wiki
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"html"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ type Message struct{ *ice.Message }
|
|||||||
func (m *Message) OptionTemplate() string {
|
func (m *Message) OptionTemplate() string {
|
||||||
res := []string{`class="story"`}
|
res := []string{`class="story"`}
|
||||||
add := func(pre, key string) {
|
add := func(pre, key string) {
|
||||||
kit.If(m.Option(key), func() { res = append(res, kit.Format(`%s%s=%q`, pre, key, m.Option(key))) })
|
kit.If(m.Option(key), func() { res = append(res, kit.Format(`%s%s=%q`, pre, key, html.EscapeString(m.Option(key)))) })
|
||||||
}
|
}
|
||||||
kit.For(kit.Split("type,name,text"), func(k string) { add("data-", k) })
|
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(m.Optionv(mdb.EXTRA), func(k string, v string) { kit.If(!strings.Contains(k, "-"), func() { add("data-", k) }) })
|
||||||
|
@ -22,7 +22,7 @@ const WORD = "word"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
WORD: {Name: "word path=src/main.shy@key auto play", Help: "笔记文档", Actions: ice.MergeActions(ice.Actions{
|
WORD: {Name: "word path=src/main.shy@key auto play", Help: "上下文", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
WordAlias(m, NAVMENU, TITLE, NAVMENU)
|
WordAlias(m, NAVMENU, TITLE, NAVMENU)
|
||||||
WordAlias(m, PREMENU, TITLE, PREMENU)
|
WordAlias(m, PREMENU, TITLE, PREMENU)
|
||||||
|
3
exec.go
3
exec.go
@ -59,9 +59,10 @@ func (m *Message) Sleep300ms(arg ...Any) *Message { return m.Sleep("300ms", arg.
|
|||||||
func (m *Message) Sleep30ms(arg ...Any) *Message { return m.Sleep("30ms", arg...) }
|
func (m *Message) Sleep30ms(arg ...Any) *Message { return m.Sleep("30ms", arg...) }
|
||||||
func (m *Message) Sleep3s(arg ...Any) *Message { return m.Sleep("3s", arg...) }
|
func (m *Message) Sleep3s(arg ...Any) *Message { return m.Sleep("3s", arg...) }
|
||||||
func (m *Message) GoSleep(t string, arg ...Any) { m.Go(func() { m.Sleep(t).Cmd(arg...) }) }
|
func (m *Message) GoSleep(t string, arg ...Any) { m.Go(func() { m.Sleep(t).Cmd(arg...) }) }
|
||||||
func (m *Message) Go(cb func(), arg ...Any) {
|
func (m *Message) Go(cb func(), arg ...Any) *Message {
|
||||||
kit.If(len(arg) == 0, func() { arg = append(arg, logs.FileLine(cb)) })
|
kit.If(len(arg) == 0, func() { arg = append(arg, logs.FileLine(cb)) })
|
||||||
task.Put(arg[0], func(task *task.Task) { m.TryCatch(m, true, func(m *Message) { cb() }) })
|
task.Put(arg[0], func(task *task.Task) { m.TryCatch(m, true, func(m *Message) { cb() }) })
|
||||||
|
return m
|
||||||
}
|
}
|
||||||
func (m *Message) Wait(cb ...Handler) (wait func(), done Handler) {
|
func (m *Message) Wait(cb ...Handler) (wait func(), done Handler) {
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
|
4
info.go
4
info.go
@ -1,10 +1,12 @@
|
|||||||
package ice
|
package ice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
|
"shylinux.com/x/toolkits/miss"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MakeInfo struct {
|
type MakeInfo struct {
|
||||||
@ -44,6 +46,7 @@ var Info = struct {
|
|||||||
|
|
||||||
merges []Any
|
merges []Any
|
||||||
render map[string]func(*Message, ...Any) string
|
render map[string]func(*Message, ...Any) string
|
||||||
|
OpenFile func(m *Message, p string) (io.ReadCloser, error)
|
||||||
Load func(m *Message, key ...string) *Message
|
Load func(m *Message, key ...string) *Message
|
||||||
Save func(m *Message, key ...string) *Message
|
Save func(m *Message, key ...string) *Message
|
||||||
Log func(m *Message, p, l, s string)
|
Log func(m *Message, p, l, s string)
|
||||||
@ -57,6 +60,7 @@ var Info = struct {
|
|||||||
Stack: map[string]func(m *Message, key string, arg ...Any) Any{},
|
Stack: map[string]func(m *Message, key string, arg ...Any) Any{},
|
||||||
|
|
||||||
render: map[string]func(*Message, ...Any) string{},
|
render: map[string]func(*Message, ...Any) string{},
|
||||||
|
OpenFile: func(m *Message, p string) (io.ReadCloser, error) { return miss.OpenFile(p) },
|
||||||
Load: func(m *Message, key ...string) *Message { return m },
|
Load: func(m *Message, key ...string) *Message { return m },
|
||||||
Save: func(m *Message, key ...string) *Message { return m },
|
Save: func(m *Message, key ...string) *Message { return m },
|
||||||
Log: func(m *Message, p, l, s string) {},
|
Log: func(m *Message, p, l, s string) {},
|
||||||
|
@ -199,7 +199,7 @@ func _repos_status(m *ice.Message, p string, repos *git.Repository) error {
|
|||||||
tree, err = commit.Tree()
|
tree, err = commit.Tree()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Cmd(nfs.DIR, ice.USR_LOCAL_EXPORT, kit.Dict(nfs.DIR_DEEP, ice.TRUE, nfs.DIR_TYPE, nfs.TYPE_CAT), func(value ice.Maps) {
|
m.Cmd(nfs.DIR, ice.USR_LOCAL_EXPORT, kit.Dict(ice.MSG_FILES, nfs.DiskFile, nfs.DIR_DEEP, ice.TRUE, nfs.DIR_TYPE, nfs.TYPE_CAT), func(value ice.Maps) {
|
||||||
if _, ok := status[value[nfs.PATH]]; ok {
|
if _, ok := status[value[nfs.PATH]]; ok {
|
||||||
return
|
return
|
||||||
} else if tree != nil {
|
} else if tree != nil {
|
||||||
@ -355,17 +355,11 @@ const (
|
|||||||
const REPOS = "repos"
|
const REPOS = "repos"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cache := ""
|
cache := ice.USR_REQUIRE
|
||||||
web.Index.MergeCommands(ice.Commands{
|
web.Index.MergeCommands(ice.Commands{
|
||||||
web.PP(ice.REQUIRE): {Name: "/require/shylinux.com/x/volcanos/proto.js", Actions: ice.MergeActions(ice.Actions{
|
web.PP(ice.REQUIRE): {Name: "/require/shylinux.com/x/volcanos/proto.js", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
cache = kit.GetValid(
|
kit.If(cli.SystemFind(m, code.GO), func() { cache = code.GoCache(m) })
|
||||||
func() string { return ice.Pulse.Cmdx(cli.SYSTEM, "go", "env", "GOMODCACHE") },
|
|
||||||
func() string {
|
|
||||||
return kit.Select(kit.HomePath("go")+nfs.PS, ice.Pulse.Cmdx(cli.SYSTEM, "go", "env", "GOPATH")) + "/pkg/mod/"
|
|
||||||
},
|
|
||||||
func() string { return ice.USR_REQUIRE },
|
|
||||||
)
|
|
||||||
}},
|
}},
|
||||||
}), Hand: func(m *ice.Message, arg ...string) {
|
}), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) < 4 {
|
if len(arg) < 4 {
|
||||||
@ -393,6 +387,9 @@ func init() {
|
|||||||
m.Cmd(nfs.DIR, nfs.USR, func(value ice.Maps) { _repos_insert(m, value[nfs.PATH]) })
|
m.Cmd(nfs.DIR, nfs.USR, func(value ice.Maps) { _repos_insert(m, value[nfs.PATH]) })
|
||||||
_repos_insert(m, kit.Path(""))
|
_repos_insert(m, kit.Path(""))
|
||||||
}},
|
}},
|
||||||
|
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
mdb.IsSearchForEach(m, arg, func() []string { return []string{ice.CMD, m.PrefixKey()} })
|
||||||
|
}},
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case COMMENT:
|
case COMMENT:
|
||||||
@ -514,11 +511,9 @@ func init() {
|
|||||||
m.Push(BRANCH, refer.Name().Short())
|
m.Push(BRANCH, refer.Name().Short())
|
||||||
m.Push(mdb.HASH, refer.Hash().String())
|
m.Push(mdb.HASH, refer.Hash().String())
|
||||||
}
|
}
|
||||||
if iter, err := repos.Tags(); err == nil {
|
if refer := _repos_recent(m, repos); refer != nil {
|
||||||
if refer, err := iter.Next(); err == nil {
|
|
||||||
m.Push(nfs.VERSION, refer.Name().Short())
|
m.Push(nfs.VERSION, refer.Name().Short())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if cfg, err := config.LoadConfig(config.GlobalScope); err == nil {
|
if cfg, err := config.LoadConfig(config.GlobalScope); err == nil {
|
||||||
m.Push(aaa.EMAIL, kit.Select(m.Option(ice.MSG_USERNAME)+"@163.com", cfg.User.Email))
|
m.Push(aaa.EMAIL, kit.Select(m.Option(ice.MSG_USERNAME)+"@163.com", cfg.User.Email))
|
||||||
m.Push(aaa.USERNAME, kit.Select(m.Option(ice.MSG_USERNAME), cfg.User.Name))
|
m.Push(aaa.USERNAME, kit.Select(m.Option(ice.MSG_USERNAME), cfg.User.Name))
|
||||||
|
@ -129,7 +129,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
kit.If(m.Option(nfs.TO), func() { _git_cmd(m, CONFIG, "--global", "url."+m.Option(nfs.TO)+".insteadof", m.Option(nfs.FROM)) })
|
kit.If(m.Option(nfs.TO), func() { _git_cmd(m, CONFIG, "--global", "url."+m.Option(nfs.TO)+".insteadof", m.Option(nfs.FROM)) })
|
||||||
}},
|
}},
|
||||||
CONFIGS: {Name: "configs email* username*", Help: "配置", Hand: func(m *ice.Message, arg ...string) {
|
CONFIGS: {Name: "configs email* username* token", Help: "配置", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(nfs.DEFS, kit.HomePath(".gitconfig"), nfs.Template(m, "gitconfig", m.Option(aaa.USERNAME), m.Option(aaa.EMAIL)))
|
m.Cmd(nfs.DEFS, kit.HomePath(".gitconfig"), nfs.Template(m, "gitconfig", m.Option(aaa.USERNAME), m.Option(aaa.EMAIL)))
|
||||||
mdb.Config(m, aaa.USERNAME, m.Option(aaa.USERNAME))
|
mdb.Config(m, aaa.USERNAME, m.Option(aaa.USERNAME))
|
||||||
mdb.Config(m, aaa.EMAIL, m.Option(aaa.EMAIL))
|
mdb.Config(m, aaa.EMAIL, m.Option(aaa.EMAIL))
|
||||||
@ -137,6 +137,9 @@ func init() {
|
|||||||
OAUTH: {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
OAUTH: {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.ProcessOpen(kit.MergeURL2(kit.Select(ice.Info.Make.Domain, _git_remote(m)), web.ChatCmdPath(Prefix(TOKEN), "gen"), tcp.HOST, m.Option(ice.MSG_USERWEB)))
|
m.ProcessOpen(kit.MergeURL2(kit.Select(ice.Info.Make.Domain, _git_remote(m)), web.ChatCmdPath(Prefix(TOKEN), "gen"), tcp.HOST, m.Option(ice.MSG_USERWEB)))
|
||||||
}},
|
}},
|
||||||
|
cli.RESTART: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Go(func() { m.Cmd(ice.EXIT, "1") }).ProcessHold()
|
||||||
|
}},
|
||||||
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Option(mdb.TYPE) != web.WORKER {
|
if m.Option(mdb.TYPE) != web.WORKER {
|
||||||
return
|
return
|
||||||
@ -163,10 +166,8 @@ func init() {
|
|||||||
} else if config, err := config.LoadConfig(config.GlobalScope); err == nil && config.User.Email == "" && mdb.Config(m, aaa.EMAIL) == "" {
|
} else if config, err := config.LoadConfig(config.GlobalScope); err == nil && config.User.Email == "" && mdb.Config(m, aaa.EMAIL) == "" {
|
||||||
m.Action(CONFIGS).Echo("please config email and name. ").EchoButton(CONFIGS)
|
m.Action(CONFIGS).Echo("please config email and name. ").EchoButton(CONFIGS)
|
||||||
} else if len(arg) == 0 {
|
} else if len(arg) == 0 {
|
||||||
if config != nil {
|
kit.If(config != nil, func() { m.Option(aaa.EMAIL, kit.Select(mdb.Config(m, aaa.EMAIL), config.User.Email)) })
|
||||||
m.Option(aaa.EMAIL, kit.Select(mdb.Config(m, aaa.EMAIL), config.User.Email))
|
m.Cmdy(REPOS, STATUS).Action(PULL, PUSH, "oauth", CONFIGS, cli.RESTART)
|
||||||
}
|
|
||||||
m.Cmdy(REPOS, STATUS).Action(PULL, PUSH, "oauth", CONFIGS)
|
|
||||||
} else {
|
} else {
|
||||||
m.Cmdy(REPOS, arg[0], MASTER, INDEX, m.Cmdv(REPOS, arg[0], MASTER, INDEX, nfs.FILE))
|
m.Cmdy(REPOS, arg[0], MASTER, INDEX, m.Cmdv(REPOS, arg[0], MASTER, INDEX, nfs.FILE))
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,14 @@ func init() {
|
|||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TOKEN: {Name: "token username auto prunes", Help: "令牌", Actions: ice.MergeActions(ice.Actions{
|
TOKEN: {Name: "token username auto prunes", Help: "令牌", Actions: ice.MergeActions(ice.Actions{
|
||||||
GEN: {Hand: func(m *ice.Message, arg ...string) {
|
GEN: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Echo("请授权 %s 代码权限\n", m.Option(tcp.HOST)).EchoButton("confirm")
|
||||||
|
}},
|
||||||
|
"confirm": {Hand: func(m *ice.Message, arg ...string) {
|
||||||
msg := m.Cmd("", m.Option(ice.MSG_USERNAME))
|
msg := m.Cmd("", m.Option(ice.MSG_USERNAME))
|
||||||
if msg.Append(mdb.TIME) < m.Time() {
|
if msg.Append(mdb.TIME) < m.Time() {
|
||||||
msg = m.Cmd("", mdb.CREATE, aaa.USERNAME, m.Option(ice.MSG_USERNAME), TOKEN, kit.Hashs(mdb.UNIQ)).Cmd("", m.Option(ice.MSG_USERNAME))
|
msg = m.Cmd("", mdb.CREATE, aaa.USERNAME, m.Option(ice.MSG_USERNAME), TOKEN, kit.Hashs(mdb.UNIQ)).Cmd("", m.Option(ice.MSG_USERNAME))
|
||||||
}
|
}
|
||||||
if !m.Warn(!strings.HasPrefix(m.Option(tcp.HOST), "http://localhost:"), ice.ErrNotRight, m.Option(tcp.HOST)) {
|
|
||||||
m.ProcessReplace(kit.MergeURL2(m.Option(tcp.HOST), web.ChatCmdPath(m.PrefixKey(), SET), TOKEN, strings.Replace(web.UserHost(m), "://", kit.Format("://%s:%s@", m.Option(ice.MSG_USERNAME), msg.Append(TOKEN)), 1)))
|
m.ProcessReplace(kit.MergeURL2(m.Option(tcp.HOST), web.ChatCmdPath(m.PrefixKey(), SET), TOKEN, strings.Replace(web.UserHost(m), "://", kit.Format("://%s:%s@", m.Option(ice.MSG_USERNAME), msg.Append(TOKEN)), 1)))
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
SET: {Hand: func(m *ice.Message, arg ...string) {
|
SET: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
host, list := ice.Map{kit.ParseURL(m.Option(TOKEN)).Host: true}, []string{m.Option(TOKEN)}
|
host, list := ice.Map{kit.ParseURL(m.Option(TOKEN)).Host: true}, []string{m.Option(TOKEN)}
|
||||||
@ -41,8 +42,7 @@ func init() {
|
|||||||
m.ProcessClose()
|
m.ProcessClose()
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, aaa.USERNAME, mdb.FIELD, "time,username,token")), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, aaa.USERNAME, mdb.FIELD, "time,username,token")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
mdb.HashSelect(m, arg...)
|
if mdb.HashSelect(m, arg...); len(arg) > 0 {
|
||||||
if len(arg) > 0 {
|
|
||||||
u := kit.ParseURL(m.Option(ice.MSG_USERWEB))
|
u := kit.ParseURL(m.Option(ice.MSG_USERWEB))
|
||||||
m.EchoScript(kit.Format("%s://%s:%s@%s", u.Scheme, m.Append(aaa.USERNAME), m.Append(TOKEN), u.Host))
|
m.EchoScript(kit.Format("%s://%s:%s@%s", u.Scheme, m.Append(aaa.USERNAME), m.Append(TOKEN), u.Host))
|
||||||
m.EchoScript(kit.Format("echo '%s://%s:%s@%s' >>~/.git-credentials", u.Scheme, m.Append(aaa.USERNAME), m.Append(TOKEN), u.Host))
|
m.EchoScript(kit.Format("echo '%s://%s:%s@%s' >>~/.git-credentials", u.Scheme, m.Append(aaa.USERNAME), m.Append(TOKEN), u.Host))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user