mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 09:34:05 +08:00
opt git.status
This commit is contained in:
parent
63bcfea410
commit
e167f23c70
@ -53,7 +53,7 @@ func init() {
|
|||||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
COMMAND: {Name: "command key auto", Help: "命令", Action: map[string]*ice.Action{
|
COMMAND: {Name: "command key auto", Help: "命令", Action: map[string]*ice.Action{
|
||||||
mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if arg[0] == COMMAND {
|
if arg[0] == COMMAND || arg[1] != "" {
|
||||||
_command_search(m, arg[0], arg[1], arg[2])
|
_command_search(m, arg[0], arg[1], arg[2])
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
@ -432,7 +432,7 @@ const (
|
|||||||
const MDB = "mdb"
|
const MDB = "mdb"
|
||||||
|
|
||||||
var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*ice.Command{
|
var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*ice.Command{
|
||||||
INSERT: {Name: "insert conf key type arg...", Help: "添加", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
INSERT: {Name: "insert key sub type arg...", Help: "添加", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch arg[2] {
|
switch arg[2] {
|
||||||
case HASH:
|
case HASH:
|
||||||
_hash_insert(m, arg[0], _domain_chain(m, arg[1]), arg[3:]...)
|
_hash_insert(m, arg[0], _domain_chain(m, arg[1]), arg[3:]...)
|
||||||
@ -440,7 +440,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*
|
|||||||
_list_insert(m, arg[0], _domain_chain(m, arg[1]), arg[3:]...)
|
_list_insert(m, arg[0], _domain_chain(m, arg[1]), arg[3:]...)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
DELETE: {Name: "delete conf key type field value", Help: "删除", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
DELETE: {Name: "delete key sub type field value", Help: "删除", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch arg[2] {
|
switch arg[2] {
|
||||||
case HASH:
|
case HASH:
|
||||||
_hash_delete(m, arg[0], _domain_chain(m, arg[1]), arg[3], arg[4])
|
_hash_delete(m, arg[0], _domain_chain(m, arg[1]), arg[3], arg[4])
|
||||||
@ -448,7 +448,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*
|
|||||||
_list_delete(m, arg[0], _domain_chain(m, arg[1]), arg[3], arg[4])
|
_list_delete(m, arg[0], _domain_chain(m, arg[1]), arg[3], arg[4])
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
MODIFY: {Name: "modify conf key type field value arg...", Help: "编辑", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
MODIFY: {Name: "modify key sub type field value arg...", Help: "编辑", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch arg[2] {
|
switch arg[2] {
|
||||||
case HASH:
|
case HASH:
|
||||||
_hash_modify(m, arg[0], _domain_chain(m, arg[1]), arg[3], arg[4], arg[5:]...)
|
_hash_modify(m, arg[0], _domain_chain(m, arg[1]), arg[3], arg[4], arg[5:]...)
|
||||||
@ -456,7 +456,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*
|
|||||||
_list_modify(m, arg[0], _domain_chain(m, arg[1]), arg[3], arg[4], arg[5:]...)
|
_list_modify(m, arg[0], _domain_chain(m, arg[1]), arg[3], arg[4], arg[5:]...)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
SELECT: {Name: "select conf key type field value", Help: "查询", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
SELECT: {Name: "select key sub type field value", Help: "查询", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch arg[2] {
|
switch arg[2] {
|
||||||
case HASH:
|
case HASH:
|
||||||
_hash_select(m, arg[0], _domain_chain(m, arg[1]), kit.Select("", arg, 3), kit.Select(kit.MDB_FOREACH, arg, 4))
|
_hash_select(m, arg[0], _domain_chain(m, arg[1]), kit.Select("", arg, 3), kit.Select(kit.MDB_FOREACH, arg, 4))
|
||||||
@ -466,7 +466,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*
|
|||||||
_zone_select(m, arg[0], _domain_chain(m, arg[1]), kit.Select("", arg, 3), kit.Select("", arg, 4))
|
_zone_select(m, arg[0], _domain_chain(m, arg[1]), kit.Select("", arg, 3), kit.Select("", arg, 4))
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
EXPORT: {Name: "export conf key type file", Help: "导出", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
EXPORT: {Name: "export key sub type file", Help: "导出", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch file := _file_name(m, arg...); arg[2] {
|
switch file := _file_name(m, arg...); arg[2] {
|
||||||
case HASH:
|
case HASH:
|
||||||
_hash_export(m, arg[0], _domain_chain(m, arg[1]), file)
|
_hash_export(m, arg[0], _domain_chain(m, arg[1]), file)
|
||||||
@ -476,7 +476,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*
|
|||||||
_zone_export(m, arg[0], _domain_chain(m, arg[1]), file)
|
_zone_export(m, arg[0], _domain_chain(m, arg[1]), file)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
IMPORT: {Name: "import conf key type file", Help: "导入", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
IMPORT: {Name: "import key sub type file", Help: "导入", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch file := _file_name(m, arg...); arg[2] {
|
switch file := _file_name(m, arg...); arg[2] {
|
||||||
case HASH:
|
case HASH:
|
||||||
_hash_import(m, arg[0], _domain_chain(m, arg[1]), file)
|
_hash_import(m, arg[0], _domain_chain(m, arg[1]), file)
|
||||||
@ -486,7 +486,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*
|
|||||||
_zone_import(m, arg[0], _domain_chain(m, arg[1]), file)
|
_zone_import(m, arg[0], _domain_chain(m, arg[1]), file)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
PRUNES: {Name: "prunes conf key type [field value]...", Help: "清理", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
PRUNES: {Name: "prunes key sub type [field value]...", Help: "清理", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch arg[2] {
|
switch arg[2] {
|
||||||
case HASH:
|
case HASH:
|
||||||
_hash_prunes(m, arg[0], _domain_chain(m, arg[1]), arg[3:]...)
|
_hash_prunes(m, arg[0], _domain_chain(m, arg[1]), arg[3:]...)
|
||||||
@ -494,7 +494,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*
|
|||||||
_list_prunes(m, arg[0], _domain_chain(m, arg[1]), arg[3:]...)
|
_list_prunes(m, arg[0], _domain_chain(m, arg[1]), arg[3:]...)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
INPUTS: {Name: "inputs conf key type field value", Help: "补全", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
INPUTS: {Name: "inputs key sub type field value", Help: "补全", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch arg[2] {
|
switch arg[2] {
|
||||||
case HASH:
|
case HASH:
|
||||||
_hash_inputs(m, arg[0], _domain_chain(m, arg[1]), kit.Select("name", arg, 3), kit.Select("", arg, 4))
|
_hash_inputs(m, arg[0], _domain_chain(m, arg[1]), kit.Select("name", arg, 3), kit.Select("", arg, 4))
|
||||||
|
10
conf.go
10
conf.go
@ -51,14 +51,16 @@ const ( // MSG
|
|||||||
MSG_SOURCE = "_source"
|
MSG_SOURCE = "_source"
|
||||||
MSG_TARGET = "_target"
|
MSG_TARGET = "_target"
|
||||||
MSG_HANDLE = "_handle"
|
MSG_HANDLE = "_handle"
|
||||||
MSG_ACTION = "_action"
|
|
||||||
MSG_DAEMON = "_daemon"
|
|
||||||
MSG_UPLOAD = "_upload"
|
|
||||||
MSG_OUTPUT = "_output"
|
MSG_OUTPUT = "_output"
|
||||||
MSG_ARGS = "_args"
|
MSG_ARGS = "_args"
|
||||||
|
|
||||||
MSG_PROCESS = "_process"
|
MSG_DAEMON = "_daemon"
|
||||||
|
MSG_UPLOAD = "_upload"
|
||||||
|
MSG_ACTION = "_action"
|
||||||
|
MSG_STATUS = "_status"
|
||||||
|
|
||||||
MSG_CONTROL = "_control"
|
MSG_CONTROL = "_control"
|
||||||
|
MSG_PROCESS = "_process"
|
||||||
MSG_DISPLAY = "_display"
|
MSG_DISPLAY = "_display"
|
||||||
|
|
||||||
MSG_CMDS = "cmds"
|
MSG_CMDS = "cmds"
|
||||||
|
@ -36,6 +36,8 @@ func _header_share(m *ice.Message, arg ...string) {
|
|||||||
link = strings.Replace(link, tcp.LOCALHOST, m.Cmd(tcp.HOST, ice.OptionFields(tcp.IP)).Append(tcp.IP), 1)
|
link = strings.Replace(link, tcp.LOCALHOST, m.Cmd(tcp.HOST, ice.OptionFields(tcp.IP)).Append(tcp.IP), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m.Set(kit.MDB_NAME)
|
||||||
|
m.Set(kit.MDB_TEXT)
|
||||||
m.Push(kit.MDB_NAME, link)
|
m.Push(kit.MDB_NAME, link)
|
||||||
m.PushQRCode(kit.MDB_TEXT, link)
|
m.PushQRCode(kit.MDB_TEXT, link)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
"github.com/shylinux/icebergs/base/nfs"
|
"github.com/shylinux/icebergs/base/nfs"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -62,12 +61,6 @@ func _pack_volcanos(m *ice.Message, pack *os.File, dir string) {
|
|||||||
}
|
}
|
||||||
for _, k := range []string{"lib", "page", "panel", "plugin"} {
|
for _, k := range []string{"lib", "page", "panel", "plugin"} {
|
||||||
m.Cmd(nfs.DIR, k).Table(func(index int, value map[string]string, head []string) {
|
m.Cmd(nfs.DIR, k).Table(func(index int, value map[string]string, head []string) {
|
||||||
if value[kit.MDB_PATH] == "page/index.html" {
|
|
||||||
pack.WriteString(fmt.Sprintf(" \"%s/%s\": %s,\n",
|
|
||||||
m.Conf(web.SERVE, kit.Keym(ice.VOLCANOS, kit.MDB_PATH)), value[kit.MDB_PATH],
|
|
||||||
_pack_file(m, path.Join(dir, value[kit.MDB_PATH]))))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
pack.WriteString(fmt.Sprintf(" \"/%s\": %s,\n",
|
pack.WriteString(fmt.Sprintf(" \"/%s\": %s,\n",
|
||||||
value[kit.MDB_PATH], _pack_file(m, path.Join(dir, value[kit.MDB_PATH]))))
|
value[kit.MDB_PATH], _pack_file(m, path.Join(dir, value[kit.MDB_PATH]))))
|
||||||
})
|
})
|
||||||
|
@ -106,11 +106,16 @@ echo "hello world"
|
|||||||
}},
|
}},
|
||||||
ice.CONTEXTS: {Name: "contexts", Help: "环境", Hand: func(m *ice.Message, arg ...string) {
|
ice.CONTEXTS: {Name: "contexts", Help: "环境", Hand: func(m *ice.Message, arg ...string) {
|
||||||
u := kit.ParseURL(m.Option(ice.MSG_USERWEB))
|
u := kit.ParseURL(m.Option(ice.MSG_USERWEB))
|
||||||
m.Option("httphost", fmt.Sprintf("%s://%s:%s", u.Scheme, strings.Split(u.Host, ":")[0], kit.Select(kit.Select("80", "443", u.Scheme == "https"), strings.Split(u.Host, ":"), 1)))
|
host := u.Host
|
||||||
m.Option("hostport", fmt.Sprintf("%s:%s", strings.Split(u.Host, ":")[0], kit.Select(kit.Select("80", "443", u.Scheme == "https"), strings.Split(u.Host, ":"), 1)))
|
if strings.Contains(host, "localhost") {
|
||||||
m.Option("hostname", strings.Split(u.Host, ":")[0])
|
host = strings.Replace(host, "localhost", m.Cmd(tcp.HOST).Append(tcp.IP), 1)
|
||||||
|
}
|
||||||
|
|
||||||
m.Option("userhost", fmt.Sprintf("%s@%s", m.Option(ice.MSG_USERNAME), strings.Split(u.Host, ":")[0]))
|
m.Option("httphost", fmt.Sprintf("%s://%s:%s", u.Scheme, strings.Split(host, ":")[0], kit.Select(kit.Select("80", "443", u.Scheme == "https"), strings.Split(host, ":"), 1)))
|
||||||
|
m.Option("hostport", fmt.Sprintf("%s:%s", strings.Split(host, ":")[0], kit.Select(kit.Select("80", "443", u.Scheme == "https"), strings.Split(host, ":"), 1)))
|
||||||
|
m.Option("hostname", strings.Split(host, ":")[0])
|
||||||
|
|
||||||
|
m.Option("userhost", fmt.Sprintf("%s@%s", m.Option(ice.MSG_USERNAME), strings.Split(host, ":")[0]))
|
||||||
m.Option("hostpath", kit.Path("./.ish/pluged"))
|
m.Option("hostpath", kit.Path("./.ish/pluged"))
|
||||||
|
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
|
@ -274,7 +274,7 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 渲染引擎
|
// 渲染引擎
|
||||||
m.Option("meta", data)
|
m.Option(kit.MDB_META, data)
|
||||||
m.Render(ice.RENDER_TEMPLATE, m.Conf(FIELD, kit.Keym(kit.MDB_TEMPLATE)))
|
m.Render(ice.RENDER_TEMPLATE, m.Conf(FIELD, kit.Keym(kit.MDB_TEMPLATE)))
|
||||||
}
|
}
|
||||||
func _other_show(m *ice.Message, name, text string, arg ...string) {
|
func _other_show(m *ice.Message, name, text string, arg ...string) {
|
||||||
|
7
init.go
7
init.go
@ -206,6 +206,13 @@ func DumpBinPack(w io.Writer, name string, cb func(string)) bool {
|
|||||||
w.Write(b)
|
w.Write(b)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if b, ok := BinPack[strings.TrimPrefix(name, "usr/volcanos")]; ok {
|
||||||
|
if cb != nil {
|
||||||
|
cb(name)
|
||||||
|
}
|
||||||
|
w.Write(b)
|
||||||
|
return true
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
27
misc.go
27
misc.go
@ -5,6 +5,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
)
|
)
|
||||||
@ -257,6 +258,14 @@ func OptionFields(str string) Option { return Option{"fields", str} }
|
|||||||
func OptionHash(str string) Option { return Option{kit.MDB_HASH, str} }
|
func OptionHash(str string) Option { return Option{kit.MDB_HASH, str} }
|
||||||
|
|
||||||
func (m *Message) Toast(content string, arg ...interface{}) {
|
func (m *Message) Toast(content string, arg ...interface{}) {
|
||||||
|
if len(arg) > 1 {
|
||||||
|
switch val := arg[1].(type) {
|
||||||
|
case string:
|
||||||
|
if value, err := time.ParseDuration(val); err == nil {
|
||||||
|
arg[1] = int(value / time.Millisecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
m.Cmd("web.space", m.Option("_daemon"), "toast", "", content, arg)
|
m.Cmd("web.space", m.Option("_daemon"), "toast", "", content, arg)
|
||||||
}
|
}
|
||||||
func (m *Message) GoToast(title string, cb func(func(string, int, int))) {
|
func (m *Message) GoToast(title string, cb func(func(string, int, int))) {
|
||||||
@ -284,3 +293,21 @@ func (m *Message) Process(action string, arg ...interface{}) {
|
|||||||
}
|
}
|
||||||
func (m *Message) ProcessHold() { m.Process(PROCESS_HOLD) }
|
func (m *Message) ProcessHold() { m.Process(PROCESS_HOLD) }
|
||||||
func (m *Message) ProcessBack() { m.Process(PROCESS_BACK) }
|
func (m *Message) ProcessBack() { m.Process(PROCESS_BACK) }
|
||||||
|
|
||||||
|
func (m *Message) ProcessRefresh(delay string) {
|
||||||
|
if d, e := time.ParseDuration(delay); e == nil {
|
||||||
|
m.Option("_delay", int(d/time.Millisecond))
|
||||||
|
}
|
||||||
|
m.Process(PROCESS_REFRESH)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Message) Status(arg ...interface{}) {
|
||||||
|
args := kit.Simple(arg)
|
||||||
|
list := []map[string]string{}
|
||||||
|
for i := 0; i < len(args)-1; i += 2 {
|
||||||
|
list = append(list, map[string]string{
|
||||||
|
"name": args[i], "value": args[i+1],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
m.Option(MSG_STATUS, kit.Format(list))
|
||||||
|
}
|
||||||
|
@ -12,19 +12,33 @@ import (
|
|||||||
const CONFIG = "config"
|
const CONFIG = "config"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
Index.Merge(&ice.Context{
|
||||||
|
Configs: map[string]*ice.Config{
|
||||||
|
CONFIG: {Name: CONFIG, Help: "配置键", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME)},
|
||||||
|
},
|
||||||
|
Commands: map[string]*ice.Command{
|
||||||
CONFIG: {Name: "server name auto create", Help: "配置键", Action: map[string]*ice.Action{
|
CONFIG: {Name: "server name auto create", Help: "配置键", Action: map[string]*ice.Action{
|
||||||
mdb.CREATE: {Name: "create name value", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create name value", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(cli.SYSTEM, GIT, CONFIG, "--global", m.Option(kit.MDB_NAME), m.Option(kit.MDB_VALUE))
|
m.Cmd(cli.SYSTEM, GIT, CONFIG, "--global", m.Option(kit.MDB_NAME), m.Option(kit.MDB_VALUE))
|
||||||
|
m.Cmd(mdb.DELETE, m.Prefix(CONFIG), "", kit.MDB_HASH, kit.MDB_NAME, m.Option(kit.MDB_NAME))
|
||||||
|
m.ProcessRefresh("0ms")
|
||||||
}},
|
}},
|
||||||
mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(cli.SYSTEM, GIT, CONFIG, "--global", arg)
|
if arg[0] == kit.MDB_VALUE {
|
||||||
|
m.Cmd(cli.SYSTEM, GIT, CONFIG, "--global", m.Option(kit.MDB_NAME), arg[1])
|
||||||
|
}
|
||||||
}},
|
}},
|
||||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(cli.SYSTEM, GIT, CONFIG, "--global", "--unset", m.Option(kit.MDB_NAME))
|
m.Cmd(cli.SYSTEM, GIT, CONFIG, "--global", "--unset", m.Option(kit.MDB_NAME))
|
||||||
|
m.Cmd(mdb.INSERT, m.Prefix(CONFIG), "", kit.MDB_HASH, kit.MDB_NAME, m.Option(kit.MDB_NAME), kit.MDB_VALUE, m.Option(kit.MDB_VALUE))
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
for _, v := range strings.Split(m.Cmdx(cli.SYSTEM, GIT, CONFIG, "--list"), "\n") {
|
if len(arg) > 0 {
|
||||||
|
m.Echo(m.Cmdx(cli.SYSTEM, GIT, CONFIG, "--global", arg[0]))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range strings.Split(m.Cmdx(cli.SYSTEM, GIT, CONFIG, "--global", "--list"), "\n") {
|
||||||
if ls := strings.Split(v, "="); len(ls) > 1 {
|
if ls := strings.Split(v, "="); len(ls) > 1 {
|
||||||
m.Push(kit.MDB_NAME, ls[0])
|
m.Push(kit.MDB_NAME, ls[0])
|
||||||
m.Push(kit.MDB_VALUE, ls[1])
|
m.Push(kit.MDB_VALUE, ls[1])
|
||||||
@ -32,6 +46,11 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Sort(kit.MDB_NAME)
|
m.Sort(kit.MDB_NAME)
|
||||||
|
|
||||||
|
m.Cmd(mdb.SELECT, m.Prefix(CONFIG), "", kit.MDB_HASH, ice.OptionFields("name,value")).Table(func(index int, value map[string]string, head []string) {
|
||||||
|
m.Push("", value, head)
|
||||||
|
m.PushButton(mdb.CREATE)
|
||||||
|
})
|
||||||
}},
|
}},
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ const GIT = "git"
|
|||||||
var Index = &ice.Context{Name: GIT, Help: "代码库",
|
var Index = &ice.Context{Name: GIT, Help: "代码库",
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
GIT: {Name: GIT, Help: "代码库", Value: kit.Data(
|
GIT: {Name: GIT, Help: "代码库", Value: kit.Data(
|
||||||
kit.SSH_SOURCE, "https://mirrors.edge.kernel.org/pub/software/scm/git/git-1.8.3.1.tar.gz", "config", kit.Dict(
|
kit.SSH_SOURCE, "https://mirrors.edge.kernel.org/pub/software/scm/git/git-1.8.3.1.tar.gz", CONFIG, kit.Dict(
|
||||||
"alias", kit.Dict("s", "status", "b", "branch"),
|
"alias", kit.Dict("s", "status", "b", "branch"),
|
||||||
"credential", kit.Dict("helper", "store"),
|
"credential", kit.Dict("helper", "store"),
|
||||||
"core", kit.Dict("quotepath", "false"),
|
"core", kit.Dict("quotepath", "false"),
|
||||||
@ -28,14 +28,18 @@ var Index = &ice.Context{Name: GIT, Help: "代码库",
|
|||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
_repos_insert(m, path.Base(kit.Pwd()), kit.Pwd())
|
m.Load()
|
||||||
|
|
||||||
|
_repos_insert(m, path.Base(kit.Pwd()), kit.Pwd())
|
||||||
m.Cmd(nfs.DIR, kit.SSH_USR, "name,path").Table(func(index int, value map[string]string, head []string) {
|
m.Cmd(nfs.DIR, kit.SSH_USR, "name,path").Table(func(index int, value map[string]string, head []string) {
|
||||||
_repos_insert(m, value[kit.MDB_NAME], value[kit.MDB_PATH])
|
_repos_insert(m, value[kit.MDB_NAME], value[kit.MDB_PATH])
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
m.Save(CONFIG)
|
||||||
|
}},
|
||||||
|
|
||||||
GIT: {Name: "git port path auto start build download", Help: "代码库", Action: map[string]*ice.Action{
|
GIT: {Name: "git port path auto start build download", Help: "源代码", Action: map[string]*ice.Action{
|
||||||
web.DOWNLOAD: {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
web.DOWNLOAD: {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(code.INSTALL, web.DOWNLOAD, m.Conf(GIT, kit.META_SOURCE))
|
m.Cmdy(code.INSTALL, web.DOWNLOAD, m.Conf(GIT, kit.META_SOURCE))
|
||||||
}},
|
}},
|
||||||
|
@ -73,9 +73,6 @@ func init() {
|
|||||||
|
|
||||||
_repos_insert(m, m.Option(kit.MDB_NAME), m.Option(kit.MDB_PATH))
|
_repos_insert(m, m.Option(kit.MDB_NAME), m.Option(kit.MDB_PATH))
|
||||||
}},
|
}},
|
||||||
"proxy": {Name: "proxy from to", Help: "代理", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmd(cli.SYSTEM, GIT, "config", "--global", fmt.Sprintf(`url.%s.insteadOf`, m.Option("to")), m.Option("from"))
|
|
||||||
}},
|
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 0 { // 仓库列表
|
if len(arg) == 0 { // 仓库列表
|
||||||
m.Fields(len(arg) == 0, "time,name,branch,commit,remote")
|
m.Fields(len(arg) == 0, "time,name,branch,commit,remote")
|
||||||
|
@ -24,7 +24,7 @@ func init() {
|
|||||||
SERVER: {Name: SERVER, Help: "服务器", Value: kit.Data(kit.MDB_PATH, "usr/local")},
|
SERVER: {Name: SERVER, Help: "服务器", Value: kit.Data(kit.MDB_PATH, "usr/local")},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
SERVER: {Name: "server path auto create", Help: "server", Action: map[string]*ice.Action{
|
SERVER: {Name: "server path auto create", Help: "服务器", Action: map[string]*ice.Action{
|
||||||
mdb.CREATE: {Name: "create name", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create name", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option(cli.CMD_DIR, path.Join(m.Conf(SERVER, kit.META_PATH), REPOS))
|
m.Option(cli.CMD_DIR, path.Join(m.Conf(SERVER, kit.META_PATH), REPOS))
|
||||||
m.Cmd(cli.SYSTEM, GIT, INIT, "--bare", m.Option(kit.MDB_NAME))
|
m.Cmd(cli.SYSTEM, GIT, INIT, "--bare", m.Option(kit.MDB_NAME))
|
||||||
|
@ -13,17 +13,43 @@ func _status_each(m *ice.Message, title string, cmds ...string) {
|
|||||||
count, total := 0, len(m.Confm(REPOS, kit.MDB_HASH))
|
count, total := 0, len(m.Confm(REPOS, kit.MDB_HASH))
|
||||||
toast("begin", count, total)
|
toast("begin", count, total)
|
||||||
|
|
||||||
|
list := []string{}
|
||||||
m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value map[string]string, head []string) {
|
m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value map[string]string, head []string) {
|
||||||
toast(value[kit.MDB_NAME], count, total)
|
toast(value[kit.MDB_NAME], count, total)
|
||||||
|
|
||||||
m.Cmd(cmds, ice.Option{cli.CMD_DIR, value[kit.MDB_PATH]})
|
msg := m.Cmd(cmds, ice.Option{cli.CMD_DIR, value[kit.MDB_PATH]})
|
||||||
|
if msg.Append(cli.CMD_CODE) != "0" {
|
||||||
|
list = append(list, value[kit.MDB_NAME])
|
||||||
|
m.Toast(msg.Append(cli.CMD_ERR), "error: "+value[kit.MDB_NAME], "3s")
|
||||||
|
m.Sleep("3s")
|
||||||
|
}
|
||||||
count++
|
count++
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if len(list) > 0 {
|
||||||
|
m.Toast(strings.Join(list, "\n"), "failure", "30s")
|
||||||
|
} else {
|
||||||
toast("success", count, total)
|
toast("success", count, total)
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func _status_list(m *ice.Message) {
|
func _status_stat(m *ice.Message, files, adds, dels int) (int, int, int) {
|
||||||
|
ls := kit.Split(m.Cmdx(cli.SYSTEM, GIT, DIFF, "--shortstat"), ",", ",")
|
||||||
|
for _, v := range ls {
|
||||||
|
n := kit.Int(kit.Split(strings.TrimSpace(v))[0])
|
||||||
|
switch {
|
||||||
|
case strings.Contains(v, "file"):
|
||||||
|
files += n
|
||||||
|
case strings.Contains(v, "insert"):
|
||||||
|
adds += n
|
||||||
|
case strings.Contains(v, "delet"):
|
||||||
|
dels += n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return files, adds, dels
|
||||||
|
}
|
||||||
|
func _status_list(m *ice.Message) (files, adds, dels int) {
|
||||||
m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value map[string]string, head []string) {
|
m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value map[string]string, head []string) {
|
||||||
m.Option(cli.CMD_DIR, value[kit.MDB_PATH])
|
m.Option(cli.CMD_DIR, value[kit.MDB_PATH])
|
||||||
diff := m.Cmdx(cli.SYSTEM, GIT, STATUS, "-sb")
|
diff := m.Cmdx(cli.SYSTEM, GIT, STATUS, "-sb")
|
||||||
@ -49,7 +75,10 @@ func _status_list(m *ice.Message) {
|
|||||||
}
|
}
|
||||||
m.PushButton(strings.Join(list, ","))
|
m.PushButton(strings.Join(list, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
files, adds, dels = _status_stat(m, files, adds, dels)
|
||||||
})
|
})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -65,7 +94,7 @@ const STATUS = "status"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
STATUS: {Name: "status name auto", Help: "代码状态", Action: map[string]*ice.Action{
|
STATUS: {Name: "status name auto", Help: "状态机", Action: map[string]*ice.Action{
|
||||||
PULL: {Name: "pull", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
PULL: {Name: "pull", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_status_each(m, PULL, cli.SYSTEM, GIT, PULL)
|
_status_each(m, PULL, cli.SYSTEM, GIT, PULL)
|
||||||
m.ProcessHold()
|
m.ProcessHold()
|
||||||
@ -104,13 +133,21 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
_status_list(m)
|
|
||||||
m.Action(PULL, MAKE, PUSH)
|
m.Action(PULL, MAKE, PUSH)
|
||||||
|
|
||||||
|
files, adds, dels := _status_list(m)
|
||||||
|
m.Status("files", files, "adds", adds, "dels", dels)
|
||||||
|
m.Toast(kit.Format("files: %d, adds: %d, dels: %d", files, adds, dels), ice.CONTEXTS, "3s")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Echo(m.Cmdx(cli.SYSTEM, GIT, DIFF, ice.Option{cli.CMD_DIR, _repos_path(arg[0])}))
|
m.Option(cli.CMD_DIR, _repos_path(arg[0]))
|
||||||
|
m.Echo(m.Cmdx(cli.SYSTEM, GIT, DIFF))
|
||||||
m.Action(COMMIT)
|
m.Action(COMMIT)
|
||||||
|
|
||||||
|
files, adds, dels := _status_stat(m, 0, 0, 0)
|
||||||
|
m.Status("files", files, "adds", adds, "dels", dels)
|
||||||
|
m.Toast(kit.Format("files: %d, adds: %d, dels: %d", files, adds, dels), arg[0], "3s")
|
||||||
}},
|
}},
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
6
type.go
6
type.go
@ -374,6 +374,12 @@ func (m *Message) Format(key interface{}) string {
|
|||||||
return kit.FmtTime(kit.Int64(time.Now().Sub(m.time)))
|
return kit.FmtTime(kit.Int64(time.Now().Sub(m.time)))
|
||||||
case "meta":
|
case "meta":
|
||||||
return kit.Format(m.meta)
|
return kit.Format(m.meta)
|
||||||
|
case "size":
|
||||||
|
if len(m.meta["append"]) == 0 {
|
||||||
|
return fmt.Sprintf("%dx%d", 0, 0)
|
||||||
|
} else {
|
||||||
|
return fmt.Sprintf("%dx%d", len(m.meta[m.meta["append"][0]]), len(m.meta["append"]))
|
||||||
|
}
|
||||||
case "append":
|
case "append":
|
||||||
if len(m.meta["append"]) == 0 {
|
if len(m.meta["append"]) == 0 {
|
||||||
return fmt.Sprintf("%dx%d %s", 0, 0, "[]")
|
return fmt.Sprintf("%dx%d %s", 0, 0, "[]")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user