forked from x/icebergs
opt some
This commit is contained in:
parent
d465169031
commit
b45f3e11b5
@ -208,7 +208,7 @@ func init() {
|
||||
}
|
||||
_dir_show(m, kit.Select("./", m.Option(DIR_ROOT)), arg[0],
|
||||
0, m.Options(DIR_DEEP), kit.Select(TYPE_BOTH, m.Option(DIR_TYPE)), kit.Regexp(m.Option(DIR_REG)),
|
||||
kit.Split(kit.Select("time,size,path,action", strings.Join(arg[1:], ","))))
|
||||
kit.Split(kit.Select(kit.Select("time,size,path,action", m.Option(mdb.FIELDS)), strings.Join(arg[1:], ","))))
|
||||
m.SortTimeR(kit.MDB_TIME)
|
||||
}},
|
||||
},
|
||||
|
@ -54,6 +54,12 @@ func init() {
|
||||
mdb.CREATE: {Name: "create file name", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||
_tail_create(m, arg...)
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case "file":
|
||||
m.Cmdy(DIR, kit.Select("./", arg, 1), "path")
|
||||
}
|
||||
}},
|
||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.DELETE, TAIL, "", mdb.HASH, kit.MDB_NAME, m.Option(kit.MDB_NAME))
|
||||
}},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@ -92,6 +93,13 @@ func _autogen_mod(m *ice.Message, file string) (mod string) {
|
||||
}
|
||||
|
||||
func _autogen_version(m *ice.Message) {
|
||||
if _, e := os.Stat(".git"); os.IsNotExist(e) {
|
||||
m.Cmdy(cli.SYSTEM, "git", "init")
|
||||
}
|
||||
if _, e := os.Stat("go.mod"); os.IsNotExist(e) {
|
||||
m.Cmdy(cli.SYSTEM, "go", "mod", "init", path.Base(kit.Path("")))
|
||||
}
|
||||
|
||||
file := ice.SRC_VERSION
|
||||
m.Cmd(nfs.SAVE, file, kit.Format(`package main
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package code
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@ -32,11 +33,20 @@ func init() {
|
||||
nfs.SAVE: {Name: "save type file path", Help: "保存", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(nfs.SAVE, path.Join(m.Option(kit.MDB_PATH), m.Option(kit.MDB_FILE)))
|
||||
}},
|
||||
BINPACK: {Name: "binpack", Help: "打包:生成 src/binpack.go", Hand: func(m *ice.Message, arg ...string) {
|
||||
_autogen_version(m)
|
||||
m.Cmd(BINPACK, mdb.CREATE)
|
||||
}},
|
||||
AUTOGEN: {Name: "create main=src/main.go@key key= zone= type=Zone,Hash,List,Data name=hi list= help=", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(AUTOGEN, mdb.CREATE, arg)
|
||||
}},
|
||||
COMPILE: {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(cli.SYSTEM, cli.MAKE)
|
||||
if p := os.Getenv(cli.PATH); !strings.Contains(p, "usr/local/go/bin") {
|
||||
m.Option(cli.CMD_ENV, cli.PATH, kit.Path("usr/local/go/bin")+":"+p)
|
||||
}
|
||||
if m.Cmdy(cli.SYSTEM, "go", "build", "-v", "-o", "bin/ice.bin", "src/main.go", "src/version.go"); m.Append(cli.CMD_CODE) == "0" {
|
||||
m.Cmd("exit", "1")
|
||||
}
|
||||
m.ProcessInner()
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -15,14 +17,13 @@ const PARSE = "parse"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
PARSE: {Name: "parse type=auto,json,http,form,time,list auto text:textarea", Help: "解析", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
PARSE: {Name: "parse type=auto,base64,json,http,form,time,list auto text:textarea", Help: "解析", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) < 2 {
|
||||
return
|
||||
}
|
||||
|
||||
if arg[1] = strings.TrimSpace(arg[1]); arg[0] != "auto" {
|
||||
|
||||
} else if strings.HasPrefix(arg[1], "{") || strings.HasPrefix(arg[1], "[") {
|
||||
if arg[1] = strings.TrimSpace(arg[1]); arg[0] == "auto" {
|
||||
if strings.HasPrefix(arg[1], "{") || strings.HasPrefix(arg[1], "[") {
|
||||
arg[0] = "json"
|
||||
} else if strings.HasPrefix(arg[1], "http") {
|
||||
arg[0] = "http"
|
||||
@ -33,8 +34,15 @@ func init() {
|
||||
} else {
|
||||
arg[0] = "list"
|
||||
}
|
||||
}
|
||||
|
||||
switch m.OptionFields(mdb.DETAIL); arg[0] {
|
||||
case "base64":
|
||||
buf, err := base64.StdEncoding.DecodeString(arg[1])
|
||||
if err == nil {
|
||||
m.Echo(hex.EncodeToString(buf))
|
||||
}
|
||||
|
||||
case "json":
|
||||
m.Echo(kit.Formats(kit.UnMarshal(arg[1])))
|
||||
|
||||
|
@ -22,6 +22,9 @@ func init() {
|
||||
if strings.Contains(file, "bin/") {
|
||||
return
|
||||
}
|
||||
if !strings.Contains(file, ".") {
|
||||
return
|
||||
}
|
||||
switch kit.Ext(file) {
|
||||
case "sum", "log":
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user