1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-04-08 21:05:36 +08:00
parent 5f3e62cf71
commit 21df7f027d
3 changed files with 10 additions and 8 deletions

View File

@ -52,7 +52,12 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
m.Logs(FIND, "mirrors cmd", bin)
}
}
cmd := exec.Command(kit.Select(arg[0], bin), arg[1:]...)
arg[0] = kit.Select(arg[0], bin)
if m.Cmd(SUDO, arg[0]).Length() > 0 {
m.Logs(FIND, "sudo cmd", arg[0])
arg = kit.Simple(SUDO, arg)
}
cmd := exec.Command(arg[0], arg[1:]...)
if cmd.Dir = kit.TrimPath(m.Option(CMD_DIR)); len(cmd.Dir) > 0 {
if m.Logs(EXEC, CMD_DIR, cmd.Dir); !nfs.Exists(m, cmd.Dir) {
file.MkdirAll(cmd.Dir, ice.MOD_DIR)

View File

@ -18,12 +18,9 @@ func _command_list(m *ice.Message, name string) *ice.Message {
return m.Push(mdb.INDEX, name).Push(mdb.NAME, name).Push(mdb.HELP, "").Push(mdb.META, "").Push(mdb.LIST, "")
}
m.Spawn(m.Source()).Search(name, func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
m.Push(mdb.INDEX, kit.Keys(s.Prefix(), key))
m.Push(mdb.ICONS, kit.Format(cmd.Icon))
m.Push(mdb.NAME, kit.Format(cmd.Name))
m.Push(mdb.HELP, kit.Format(cmd.Help))
m.Push(mdb.LIST, kit.Format(cmd.List))
m.Push(mdb.META, kit.Format(cmd.Meta))
m.Push(mdb.INDEX, kit.Keys(s.Prefix(), key)).Push(mdb.ICONS, kit.Format(cmd.Icon))
m.Push(mdb.NAME, kit.Format(cmd.Name)).Push(mdb.HELP, kit.Format(cmd.Help))
m.Push(mdb.LIST, kit.Format(cmd.List)).Push(mdb.META, kit.Format(cmd.Meta))
m.Push("_command", ShortCmd(kit.Keys(s.Prefix(), key)))
if !nfs.Exists(m, kit.Split(cmd.FileLine(), nfs.DF)[0], func(p string) {
m.Push("_fileline", m.FileURI(p))

View File

@ -233,7 +233,7 @@ func _space_send(m *ice.Message, name string, arg ...string) (h string) {
}
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.WarnNotValid(!ok, mdb.TARGET) {
kit.If(kit.Format(value[mdb.TYPE]) == ORIGIN, func() {
kit.If(kit.Format(value[mdb.TYPE]) == ORIGIN && target[0] != ice.OPS, func() {
m.Optionv(ice.MSG_USERWEB, kit.Simple(value[mdb.TEXT], m.Optionv(ice.MSG_USERWEB)))
m.Optionv(ice.MSG_USERPOD, kit.Simple(kit.Keys(target[1:]), m.Optionv(ice.MSG_USERPOD)))
m.Options(ice.MSG_USERHOST, "", ice.MSG_USERWEB0, m.Option(ice.MSG_USERWEB), ice.MSG_USERPOD0, name)