mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
opt some
This commit is contained in:
parent
7505c4f55f
commit
a5a6aa53a8
@ -123,11 +123,12 @@ func init() {
|
||||
}},
|
||||
STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.OptionFields(m.Config(mdb.FIELD))
|
||||
h, pid := m.Option(mdb.HASH), m.Option(PID)
|
||||
mdb.HashSelect(m, m.Option(mdb.HASH)).Tables(func(value ice.Maps) {
|
||||
if m.Option(mdb.HASH) == "" && value[PID] != m.Option(PID) {
|
||||
if h == "" && value[PID] != pid {
|
||||
return
|
||||
}
|
||||
mdb.HashModify(m, m.OptionSimple(mdb.HASH), STATUS, STOP)
|
||||
mdb.HashModify(m, mdb.HASH, value[mdb.HASH], STATUS, STOP)
|
||||
m.Cmd(gdb.SIGNAL, gdb.KILL, value[PID])
|
||||
})
|
||||
}},
|
||||
@ -148,7 +149,9 @@ func init() {
|
||||
if len(arg) == 1 {
|
||||
arg = kit.Split(arg[0])
|
||||
}
|
||||
_daemon_exec(m, _system_cmd(m, arg...))
|
||||
if _daemon_exec(m, _system_cmd(m, arg...)); IsSuccess(m) && m.Append(CMD_ERR) == "" {
|
||||
m.SetAppend()
|
||||
}
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -184,8 +184,7 @@ func init() {
|
||||
if len(arg) == 1 {
|
||||
arg = kit.Split(arg[0])
|
||||
}
|
||||
_system_exec(m, _system_cmd(m, arg...))
|
||||
if IsSuccess(m) {
|
||||
if _system_exec(m, _system_cmd(m, arg...)); IsSuccess(m) && m.Append(CMD_ERR) == "" {
|
||||
m.SetAppend()
|
||||
}
|
||||
}},
|
||||
|
@ -130,10 +130,6 @@ func CmdAction(args ...ice.Any) ice.Actions {
|
||||
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 3 && arg[1] == ACTION && arg[2] == CONFIG {
|
||||
switch arg[3] {
|
||||
case "select":
|
||||
m.Cmdy(CONFIG, arg[0])
|
||||
case "reset":
|
||||
m.Cmd(CONFIG, "reset", arg[0])
|
||||
case "help":
|
||||
if file := strings.ReplaceAll(GetCmdFile(m, arg[0]), ".go", ".shy"); nfs.ExistsFile(m, file) {
|
||||
ProcessFloat(m, "web.wiki.word", file)
|
||||
@ -146,6 +142,10 @@ func CmdAction(args ...ice.Any) ice.Actions {
|
||||
if file := GetCmdFile(m, arg[0]); nfs.ExistsFile(m, file) {
|
||||
ProcessFloat(m, "web.code.inner", file)
|
||||
}
|
||||
case "select":
|
||||
m.Cmdy(CONFIG, arg[0])
|
||||
case "reset":
|
||||
m.Cmd(CONFIG, "reset", arg[0])
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -260,6 +260,10 @@ func TravelCmd(m *ice.Message, cb func(key, file, line string)) {
|
||||
}
|
||||
|
||||
ls := kit.Split(cmd.GetFileLine(), ":")
|
||||
cb(key, strings.TrimPrefix(ls[0], kit.Path("")+ice.PS), ls[1])
|
||||
if len(ls) > 1 {
|
||||
cb(key, strings.TrimPrefix(ls[0], kit.Path("")+ice.PS), ls[1])
|
||||
} else {
|
||||
m.Warn(true, "not founc", cmd.Name)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -142,6 +142,7 @@ func init() {
|
||||
HTML, ice.TRUE, CSS, ice.TRUE, JS, ice.TRUE, GO, ice.TRUE, SH, ice.TRUE, CSV, ice.TRUE, JSON, ice.TRUE,
|
||||
SHY, ice.TRUE, "conf", ice.TRUE, "makefile", ice.TRUE, "license", ice.TRUE,
|
||||
PY, ice.TRUE, MD, ice.TRUE, TXT, ice.TRUE, IML, ice.TRUE, XML, ice.TRUE, YML, ice.TRUE, ZML, ice.TRUE,
|
||||
"configure", ice.TRUE,
|
||||
),
|
||||
)},
|
||||
}, Commands: ice.Commands{
|
||||
|
@ -30,7 +30,7 @@ func _dir_hash(m *ice.Message, p string) string {
|
||||
}
|
||||
func _dir_list(m *ice.Message, root string, name string, level int, deep bool, dir_type string, dir_reg *regexp.Regexp, fields []string) *ice.Message {
|
||||
list, e := ReadDir(m, path.Join(root, name))
|
||||
if e != nil || len(list) == 0 { // 单个文件
|
||||
if e != nil && len(list) == 0 { // 单个文件
|
||||
ls, _ := ReadDir(m, path.Dir(path.Join(root, name)))
|
||||
for _, s := range ls {
|
||||
if s.Name() == path.Base(name) {
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
|
||||
func _dream_list(m *ice.Message) *ice.Message {
|
||||
list := m.CmdMap(SPACE, mdb.NAME)
|
||||
m.Cmdy(nfs.DIR, ice.USR_LOCAL_WORK, "time,size,name", func(value ice.Maps) {
|
||||
m.Cmdy(nfs.DIR, ice.USR_LOCAL_WORK+ice.PS, "time,size,name", func(value ice.Maps) {
|
||||
if dream, ok := list[value[mdb.NAME]]; ok {
|
||||
m.Push(mdb.TYPE, dream[mdb.TYPE])
|
||||
m.Push(cli.STATUS, cli.START)
|
||||
@ -144,7 +144,7 @@ func init() {
|
||||
m.ProcessOpen(MergePod(m, m.Option(mdb.NAME)+"/cmd/web.code.vimer", "", ""))
|
||||
}},
|
||||
"xterm": {Name: "xterm", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen(MergePod(m, m.Option(mdb.NAME)+"/cmd/web.code.xterm", "", ""))
|
||||
m.ProcessOpen(MergePod(m, m.Option(mdb.NAME)+"/cmd/web.code.xterm", "hash", m.Cmdx(SPACE, m.Option(mdb.NAME), "web.code.xterm", mdb.CREATE, "type", "sh")))
|
||||
}},
|
||||
cli.STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(SPACE, mdb.MODIFY, m.OptionSimple(mdb.NAME), mdb.STATUS, cli.STOP)
|
||||
|
@ -221,7 +221,7 @@ func _space_fork(m *ice.Message) {
|
||||
case SSO:
|
||||
link := _space_domain(m)
|
||||
ls := strings.Split(kit.ParseURL(link).Path, ice.PS)
|
||||
link = kit.MergeURL2(_space_domain(m), "/chat/sso", SPACE, kit.Select("", ls, 3), "back", m.Option(ice.MSG_USERWEB))
|
||||
link = kit.MergeURL2(_space_domain(m), "/chat/sso", SPACE, kit.Select("", ls, 3), "back", m.Option("back"))
|
||||
msg.Sleep300ms(SPACE, name, cli.PWD, name, link, msg.Cmdx(cli.QRCODE, link))
|
||||
default:
|
||||
msg.Sleep300ms(SPACE, name, cli.PWD, name)
|
||||
|
5
conf.go
5
conf.go
@ -237,8 +237,9 @@ const ( // PROCESS
|
||||
PROCESS_REFRESH = "_refresh"
|
||||
PROCESS_REWRITE = "_rewrite"
|
||||
PROCESS_DISPLAY = "_display"
|
||||
PROCESS_FIELD = "_field"
|
||||
PROCESS_INNER = "_inner"
|
||||
PROCESS_FIELD = "_field"
|
||||
PROCESS_FLOAT = "_float"
|
||||
PROCESS_AGAIN = "_again"
|
||||
|
||||
PROCESS_HOLD = "_hold"
|
||||
@ -246,8 +247,8 @@ const ( // PROCESS
|
||||
PROCESS_RICH = "_rich"
|
||||
PROCESS_GROW = "_grow"
|
||||
PROCESS_OPEN = "_open"
|
||||
PROCESS_ARG = "_arg"
|
||||
|
||||
PROCESS_ARG = "_arg"
|
||||
FIELD_PREFIX = "_prefix"
|
||||
)
|
||||
const ( // CTX
|
||||
|
@ -139,9 +139,7 @@ func _install_start(m *ice.Message, arg ...string) {
|
||||
}
|
||||
|
||||
bin := kit.Split(path.Base(arg[0]), "-.")[0]
|
||||
if m.Cmdy(cli.DAEMON, kit.Select(path.Join(ice.BIN, bin), arg, 1), kit.Slice(arg, 2), args); cli.IsSuccess(m) {
|
||||
m.SetAppend()
|
||||
}
|
||||
m.Cmdy(cli.DAEMON, kit.Select(path.Join(ice.BIN, bin), arg, 1), kit.Slice(arg, 2), args)
|
||||
}
|
||||
func _install_stop(m *ice.Message, arg ...string) {
|
||||
m.Cmd(cli.DAEMON, func(value ice.Maps) {
|
||||
|
@ -95,32 +95,40 @@ func init() {
|
||||
}},
|
||||
}, Configs: ice.Configs{
|
||||
SH: {Name: SH, Help: "命令", Value: kit.Data(PLUG, kit.Dict(
|
||||
SPLIT, kit.Dict(SPACE, " ", OPERATE, "{[(.,;!|<>)]}"),
|
||||
PREFIX, kit.Dict("#!", COMMENT, "# ", COMMENT), SUFFIX, kit.Dict(" {", COMMENT),
|
||||
SPLIT, kit.Dict(OPERATE, "="),
|
||||
PREFIX, kit.Dict("#", COMMENT), SUFFIX, kit.Dict(" {", COMMENT),
|
||||
"regexp", kit.Dict(
|
||||
"[A-Z0-9_]+", CONSTANT,
|
||||
),
|
||||
PREPARE, kit.Dict(
|
||||
KEYWORD, kit.Simple(
|
||||
"require", "source", "return", "local", "export", "env",
|
||||
"local", "export", "require", "source", "return", "exit",
|
||||
|
||||
"if", "then", "else", "fi",
|
||||
"if", "then", "else", "elif", "fi",
|
||||
"for", "while", "do", "done",
|
||||
"esac", "case", "in",
|
||||
|
||||
"shift",
|
||||
"echo",
|
||||
"read",
|
||||
"eval",
|
||||
"kill",
|
||||
"let",
|
||||
"cd",
|
||||
),
|
||||
FUNCTION, kit.Simple(
|
||||
"eval",
|
||||
"test",
|
||||
"echo",
|
||||
"mkdir",
|
||||
"cat",
|
||||
"rm",
|
||||
|
||||
"env",
|
||||
"xargs", "_list",
|
||||
"date", "uptime", "uname", "whoami",
|
||||
"find", "grep", "sed", "awk",
|
||||
"pwd",
|
||||
"ls",
|
||||
"ps",
|
||||
"rm",
|
||||
"go",
|
||||
),
|
||||
), KEYWORD, kit.Dict(),
|
||||
|
@ -103,18 +103,13 @@ const CHAIN = "chain"
|
||||
|
||||
func init() {
|
||||
wiki.AddChart(CHAIN, func(m *ice.Message) wiki.Chart {
|
||||
switch m.Option("topic") {
|
||||
case "black":
|
||||
m.Option(wiki.STROKE, cli.YELLOW)
|
||||
default:
|
||||
m.Option(wiki.STROKE, cli.BLUE)
|
||||
}
|
||||
m.Option(wiki.STROKE, "")
|
||||
m.Option(wiki.FILL, "")
|
||||
m.Option(wiki.STROKE, "")
|
||||
m.Option(wiki.FONT_SIZE, "16")
|
||||
m.Option(wiki.STROKE_WIDTH, "2")
|
||||
m.Option(wiki.PADDING, "6")
|
||||
m.Option(wiki.MARGINY, "4")
|
||||
m.Option(wiki.MARGINX, "40")
|
||||
m.Option(wiki.MARGINY, "10")
|
||||
// wiki.AddGroupOption(m, SHIP, wiki.STROKE, cli.RED, wiki.FILL, cli.GLASS)
|
||||
wiki.AddGroupOption(m, SHIP, wiki.FILL, cli.GLASS)
|
||||
return &Chain{}
|
||||
})
|
||||
|
2
go.mod
2
go.mod
@ -5,6 +5,6 @@ go 1.11
|
||||
require (
|
||||
shylinux.com/x/creackpty v0.0.1
|
||||
shylinux.com/x/go-qrcode v0.0.1
|
||||
shylinux.com/x/toolkits v0.6.9
|
||||
shylinux.com/x/toolkits v0.7.0
|
||||
shylinux.com/x/websocket v0.0.1
|
||||
)
|
||||
|
4
go.sum
4
go.sum
@ -2,7 +2,7 @@ shylinux.com/x/creackpty v0.0.1 h1:o+qDE39jFsHLZB9BRAm0EI6qScjw5PuvdkROqhTcupM=
|
||||
shylinux.com/x/creackpty v0.0.1/go.mod h1:d7DnPv3oGc23WlzrN8hW7p88wNLPAO/XG4ICVEq96i0=
|
||||
shylinux.com/x/go-qrcode v0.0.1 h1:/eOGqMj1qtgs9Ymd12zTUa1gcJZs9S92kj2lb0QzKsE=
|
||||
shylinux.com/x/go-qrcode v0.0.1/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
|
||||
shylinux.com/x/toolkits v0.6.9 h1:/TWk89zZjdkOv4PQe3H19wtkgUqA90g406FsI16dAEY=
|
||||
shylinux.com/x/toolkits v0.6.9/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA=
|
||||
shylinux.com/x/toolkits v0.7.0 h1:DrfnY78IYlrJJX+N0DrmI46y5PuvfffYoDJrsZd0RvQ=
|
||||
shylinux.com/x/toolkits v0.7.0/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA=
|
||||
shylinux.com/x/websocket v0.0.1 h1:OBc21DxqsGlQ2+Pz76xqLyDNo1LV+PUUqfWi+1PZPDE=
|
||||
shylinux.com/x/websocket v0.0.1/go.mod h1:AaSpMToOxbMULKQytzczeHPuqb708vK1vrAzCxLo/XE=
|
||||
|
@ -1,6 +1,7 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
@ -42,7 +43,7 @@ const COUNT = "count"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
COUNT: {Name: "count path auto count order", Help: "代码行", Actions: ice.Actions{
|
||||
COUNT: {Name: "count path auto count order tags", Help: "代码行", Actions: ice.Actions{
|
||||
"order": {Name: "order", Help: "排行", Hand: func(m *ice.Message, arg ...string) {
|
||||
files := map[string]int{}
|
||||
_count_count(m, arg, func(file string) {
|
||||
@ -56,6 +57,26 @@ func init() {
|
||||
}
|
||||
m.StatusTimeCount().SortIntR("lines")
|
||||
}},
|
||||
"tags": {Name: "tags", Help: "索引", Hand: func(m *ice.Message, arg ...string) {
|
||||
count := map[string]int{}
|
||||
m.Cmd(nfs.CAT, path.Join(arg[0], "tags"), func(line string) {
|
||||
ls := strings.SplitN(line, ice.TB, 3)
|
||||
if len(ls) < 3 {
|
||||
return
|
||||
}
|
||||
ls = strings.SplitN(ls[2], ";\"", 2)
|
||||
if len(ls) < 2 {
|
||||
return
|
||||
}
|
||||
ls = kit.Split(ls[1])
|
||||
count[ls[0]]++
|
||||
})
|
||||
for k, v := range count {
|
||||
m.Push("type", k)
|
||||
m.Push("count", v)
|
||||
}
|
||||
m.SortIntR("count")
|
||||
}},
|
||||
COUNT: {Name: "count", Help: "计数", Hand: func(m *ice.Message, arg ...string) {
|
||||
files := map[string]int{}
|
||||
lines := map[string]int{}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/code"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -98,7 +99,7 @@ func init() {
|
||||
}
|
||||
}},
|
||||
mdb.CREATE: {Name: "create name", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(cli.CMD_ENV, TMUX, "")
|
||||
m.Option(cli.CMD_ENV, "TMUX", "")
|
||||
if m.Option(PANE) != "" { // 创建终端
|
||||
_tmux_cmd(m, SPLIT_WINDOW, "-t", _tmux_key(m.Option(SESSION), m.Option(WINDOW), m.Option(PANE)))
|
||||
|
||||
@ -156,6 +157,9 @@ func init() {
|
||||
}
|
||||
}},
|
||||
|
||||
code.XTERM: {Name: "xterm", Help: "终端", Hand: func(m *ice.Message, arg ...string) {
|
||||
code.ProcessXterm(m, []string{mdb.TYPE, "tmux attach -t " + m.Option(SESSION)}, arg...)
|
||||
}},
|
||||
SCRIPT: {Name: "script name", Help: "脚本", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(SCRIPT, m.Option(mdb.NAME), func(value ice.Maps) {
|
||||
switch value[mdb.TYPE] {
|
||||
@ -199,9 +203,9 @@ func init() {
|
||||
m.Tables(func(value ice.Maps) {
|
||||
switch value["tag"] {
|
||||
case "1":
|
||||
m.PushButton("")
|
||||
m.PushButton(code.XTERM, "")
|
||||
default:
|
||||
m.PushButton(mdb.SELECT, mdb.REMOVE)
|
||||
m.PushButton(code.XTERM, mdb.SELECT, mdb.REMOVE)
|
||||
}
|
||||
})
|
||||
}},
|
||||
|
@ -127,11 +127,11 @@ func (m *Message) ProcessDisplay(arg ...Any) {
|
||||
m.Option(MSG_DISPLAY, arg...)
|
||||
}
|
||||
|
||||
func (m *Message) ProcessInner() { m.Process(PROCESS_INNER) }
|
||||
func (m *Message) ProcessField(arg ...Any) {
|
||||
m.Process(PROCESS_FIELD)
|
||||
m.Option(FIELD_PREFIX, arg...)
|
||||
}
|
||||
func (m *Message) ProcessInner() { m.Process(PROCESS_INNER) }
|
||||
func (m *Message) ProcessAgain() { m.Process(PROCESS_AGAIN) }
|
||||
func (m *Message) ProcessHold(text ...Any) { m.Process(PROCESS_HOLD, text...) }
|
||||
func (m *Message) ProcessBack() { m.Process(PROCESS_BACK) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user