make

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Index = &ice.Context{Name: "make", Help: "构建命令",
	Caches: map[string]*ice.Cache{},
	Configs: map[string]*ice.Config{
		"make": {Name: "make", Help: "构建命令", Value: kit.Data(kit.MDB_SHORT, "name")},

		"tag": {Name: "tag", Help: "代码分析", Value: kit.Data(kit.MDB_SHORT, "name")},
	},
	Commands: map[string]*ice.Command{
		ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Load() }},
		ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},

		"tag": {Name: "tag find key index", Help: "tag", Meta: kit.Dict(
			"detail", []string{"精通", "掌握", "熟悉", "了解", "未知"},
		), List: kit.List(
			kit.MDB_INPUT, "text", "name", "file", "action", "auto",
			kit.MDB_INPUT, "text", "name", "id", "action", "auto",
			kit.MDB_INPUT, "button", "name", "查看",
			kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
		), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
			if len(arg) > 1 && arg[0] == "action" {
				switch arg[1] {
				case "精通":
				case "掌握":
				case "熟悉":
				case "了解":
				}
				m.Richs(cmd, nil, m.Option("file"), func(key string, val map[string]interface{}) {
					m.Grows(cmd, kit.Keys("hash", key), "id", m.Option("id"), func(index int, value map[string]interface{}) {
						value["status"] = arg[1]
					})
				})
				m.Grows(cmd, kit.Keys("find", m.Option("name")), "", "", func(index int, value map[string]interface{}) {
					value["status"] = arg[1]
				})
				return
			}

			if len(arg) == 0 {
				m.Richs(cmd, nil, "*", func(key string, value map[string]interface{}) {
					m.Push(key, value["meta"], []string{"type", "count", "define", "struct", "function", "file"})
				})
				m.Sort("count", "int_r")
				return
			}

			var rest []string
			var detail map[string]interface{}

			switch arg[0] {
			case "add":
				m.Conf(cmd, nil, kit.Data(kit.MDB_SHORT, "name"))
				for _, v := range arg[1:] {
					scan(m, "", v, ctags)
				}

				if m.Option("o") != "" {
					ioutil.WriteFile(m.Option("o"), []byte(m.Table().Result()), 0777)
				}
			case "find":
				if len(arg) == 1 {
					m.Grows(cmd, nil, "", "", func(index int, value map[string]interface{}) {
						m.Push("", value, []string{"id", "type", "name", "text", "line", "file"})
					})
					break
				}
				if len(arg) == 2 {
					m.Grows(cmd, kit.Keys("find", arg[1]), "", "", func(index int, value map[string]interface{}) {
						m.Push("", value, []string{"id", "type", "name", "text", "line", "file"})
					})
					break
				}

				m.Grows(cmd, kit.Keys("find", arg[1]), "id", arg[2], func(index int, value map[string]interface{}) {
					detail = value
				})
				rest = arg[3:]

			case "rand":
				m.Option("cache.limit", -2)
				for i := 0; i < kit.Int(kit.Select("5", arg, 1)); i++ {
					m.Grows(cmd, nil, "id", kit.Format(rand.Intn(kit.Int(m.Conf(cmd, "meta.count")))+1), func(index int, value map[string]interface{}) {
						m.Richs(cmd, nil, value["file"], func(key string, val map[string]interface{}) {
							m.Grows(cmd, kit.Keys("hash", key), "line", kit.Format(value["line"]), func(index int, value map[string]interface{}) {
								m.Push("", value, []string{"id", "type", "name"})
								m.Push("text", view(m, value))
								m.Push("", value, []string{"line", "file"})
							})
						})
					})
				}

			case "stat":
				stat := map[string]int{}
				m.Option("cache.limit", -2)
				m.Richs(cmd, nil, "*", func(key string, val map[string]interface{}) {
					m.Grows(cmd, kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
						stat[kit.Select("未知", value["status"])]++
						stat["总数"]++
					})
				})
				for _, k := range []string{"未知", "了解", "熟悉", "掌握", "精通", "总数"} {
					m.Push(k, stat[k])
					m.Push(k, kit.Format("%d%%", stat[k]*100/stat["总数"]))
				}

			default:
				m.Richs(cmd, nil, arg[0], func(key string, value map[string]interface{}) {
					if len(arg) == 1 {
						m.Grows(cmd, kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
							m.Push("", value, []string{"id", "status", "type", "name", "text", "line"})
						})
						return
					}

					m.Grows(cmd, kit.Keys("hash", key), "id", arg[1], func(index int, value map[string]interface{}) {
						detail = value
						rest = arg[2:]
					})
				})
			}

			if detail != nil {
				if len(rest) > 0 {
					begin, _ := kit.Render(rest[0], detail)
					end, _ := kit.Render(rest[1], detail)
					m.Cmdy(ice.CLI_SYSTEM, "sed", "-n", kit.Format("%s,%sp", string(begin), string(end)), detail["file"])
					m.Set(ice.MSG_APPEND)
					return
				}

				m.Echo(view(m, detail))
			}
		}},
		"gcc": {Name: "gcc", Help: "gcc", List: kit.List(
			kit.MDB_INPUT, "text", "name", "target", "value", "hi",
			kit.MDB_INPUT, "text", "name", "source", "value", "hi.c",
			kit.MDB_INPUT, "button", "name", "编译",
		), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
			m.Cmdy(ice.CLI_SYSTEM, cmd, "-o", arg)
			m.Set(ice.MSG_APPEND)
		}},
		"run": {Name: "run", Help: "run", List: kit.List(
			kit.MDB_INPUT, "text", "name", "target", "value", "hi",
			kit.MDB_INPUT, "button", "name", "运行",
		), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
			m.Cmdy(ice.CLI_SYSTEM, kit.Path(arg[0]))
			m.Set(ice.MSG_APPEND)
		}},
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL