mirror of
https://shylinux.com/x/icebergs
synced 2025-05-06 13:17:03 +08:00
opt tcp.port
This commit is contained in:
parent
b7e2d2d5b8
commit
9f92209b89
@ -1,8 +1,12 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/shylinux/icebergs"
|
"path"
|
||||||
"github.com/shylinux/toolkits"
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
ice "github.com/shylinux/icebergs"
|
||||||
|
kit "github.com/shylinux/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
const PYTHON = "python"
|
const PYTHON = "python"
|
||||||
@ -11,12 +15,27 @@ func init() {
|
|||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
PYTHON: {Name: "python", Help: "脚本命令", Value: kit.Data(
|
PYTHON: {Name: "python", Help: "脚本命令", Value: kit.Data(
|
||||||
PYTHON, "python", "pip", "pip",
|
"windows", "http://mirrors.sohu.com/python/3.5.2/Python-3.5.2.tar.xz",
|
||||||
|
"darwin", "http://mirrors.sohu.com/python/3.5.2/Python-3.5.2.tar.xz",
|
||||||
|
"linux", "http://mirrors.sohu.com/python/3.5.2/Python-3.5.2.tar.xz",
|
||||||
|
|
||||||
"qrcode", `import pyqrcode; print(pyqrcode.create('%s').terminal(module_color='%s', quiet_zone=1))`,
|
"qrcode", `import pyqrcode; print(pyqrcode.create('%s').terminal(module_color='%s', quiet_zone=1))`,
|
||||||
|
PYTHON, "python", "pip", "pip",
|
||||||
)},
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
PYTHON: {Name: "python cmd arg...", Help: "脚本命令", Action: map[string]*ice.Action{
|
PYTHON: {Name: "python 编译:button 下载:button", Help: "脚本命令", Action: map[string]*ice.Action{
|
||||||
|
"download": {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy("web.code.install", "download", m.Conf(PYTHON, kit.Keys(kit.MDB_META, runtime.GOOS)))
|
||||||
|
}},
|
||||||
|
"compile": {Name: "compile", Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
name := path.Base(strings.TrimSuffix(strings.TrimSuffix(m.Conf(PYTHON, kit.Keys(kit.MDB_META, runtime.GOOS)), ".tar.xz"), "zip"))
|
||||||
|
m.Option(CMD_DIR, path.Join(m.Conf("web.code.install", kit.META_PATH), name))
|
||||||
|
m.Cmdy(SYSTEM, "./configure", "--prefix="+kit.Path("usr/local"))
|
||||||
|
m.Cmdy(SYSTEM, "make", "-j8")
|
||||||
|
m.Cmdy(SYSTEM, "make", "install")
|
||||||
|
}},
|
||||||
|
|
||||||
"install": {Name: "install arg...", Help: "安装", Hand: func(m *ice.Message, arg ...string) {
|
"install": {Name: "install arg...", Help: "安装", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(SYSTEM, m.Conf(PYTHON, "meta.pip"), "install", arg)
|
m.Cmdy(SYSTEM, m.Conf(PYTHON, "meta.pip"), "install", arg)
|
||||||
}},
|
}},
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package tcp
|
package tcp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/aaa"
|
"github.com/shylinux/icebergs/base/aaa"
|
||||||
"github.com/shylinux/icebergs/base/cli"
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
@ -112,7 +115,16 @@ var Index = &ice.Context{Name: "tcp", Help: "通信模块",
|
|||||||
m.Echo(_port_get(m, ""))
|
m.Echo(_port_get(m, ""))
|
||||||
}},
|
}},
|
||||||
"select": {Name: "select [begin]", Help: "分配端口", Hand: func(m *ice.Message, arg ...string) {
|
"select": {Name: "select [begin]", Help: "分配端口", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo(_port_get(m, kit.Select("", arg, 0)))
|
port, p := kit.Select("", arg, 0), ""
|
||||||
|
for {
|
||||||
|
port = _port_get(m, port)
|
||||||
|
p = path.Join(m.Conf(cli.DAEMON, kit.META_PATH), port)
|
||||||
|
if _, e := os.Stat(p); e != nil && os.IsNotExist(e) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
port = kit.Format(kit.Int(port) + 1)
|
||||||
|
}
|
||||||
|
m.Echo(port)
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
_port_list(m)
|
_port_list(m)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user