client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2021 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MYSQL    = "mysql"
	DATABASE = "database"
)
View Source
const CLIENT = "client"
View Source
const QUERY = "query"
View Source
const SQL = "sql"

Variables

View Source
var Index = &ice.Context{Name: CLIENT, Help: "客户端",
	Configs: map[string]*ice.Config{
		CLIENT: {Name: CLIENT, Help: "客户端", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME)},
	},
	Commands: map[string]*ice.Command{
		ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
			m.Watch(server.MYSQL_SERVER_START, m.Prefix(CLIENT))
		}},
		ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
		}},

		CLIENT: {Name: "client name 执行:button create cmd:textarea", Help: "客户端", Action: map[string]*ice.Action{
			server.MYSQL_SERVER_START: {Name: "mysql.server.start", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
				m.Cmdy(mdb.INSERT, m.Prefix(CLIENT), "", mdb.HASH, arg, DATABASE, MYSQL)
			}},
			mdb.CREATE: {Name: "create name=biz username=root password=root host=localhost port=10000 database=mysql", Help: "连接", Hand: func(m *ice.Message, arg ...string) {
				m.Cmdy(mdb.INSERT, m.Prefix(CLIENT), "", mdb.HASH, arg)
			}},
			mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
				m.Cmdy(mdb.MODIFY, m.Prefix(CLIENT), "", mdb.HASH, kit.MDB_NAME, m.Option(kit.MDB_NAME), arg)
			}},
			mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
				m.Cmdy(mdb.DELETE, m.Prefix(CLIENT), "", mdb.HASH, kit.MDB_NAME, m.Option(kit.MDB_NAME))
			}},
			mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
				switch arg[0] {
				case tcp.PORT:
					m.Cmdy(server.SERVER).Appendv(ice.MSG_APPEND, kit.Split("port,time"))
				default:
					m.Option(mdb.FIELDS, "time,name,username,host,port,database")
					m.Cmdy(mdb.SELECT, m.Prefix(CLIENT), "", mdb.HASH)
				}
			}},
		}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
			if len(arg) < 2 || arg[0] == "" {
				m.Fields(len(kit.Slice(arg, 0, 1)), "time,name,username,host,port,database")
				m.Cmdy(mdb.SELECT, m.Prefix(CLIENT), "", mdb.HASH, kit.MDB_NAME, arg)
				m.PushAction(mdb.REMOVE)
				return
			}

			if dsn := _sql_meta(m, kit.Select(arg[0], kit.MDB_RANDOMS, arg[0] == "random"), ""); strings.Contains(strings.ToLower(arg[1]), "show") {
				_sql_query(m, dsn, arg[1])
			} else if strings.Contains(strings.ToLower(arg[1]), "select") {
				_sql_query(m, dsn, arg[1])
			} else {
				_sql_exec(m, dsn, arg[1])
			}
		}},
	},
}

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