1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 01:24:05 +08:00

opt windows

This commit is contained in:
harveyshao 2023-02-14 19:48:00 +08:00
parent 0ef5509ccf
commit eceea605ad
7 changed files with 38 additions and 9 deletions

View File

@ -149,7 +149,7 @@ const RUNTIME = "runtime"
func init() {
Index.MergeCommands(ice.Commands{
RUNTIME: {Name: "runtime info=bootinfo,ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,api,cli,cmd,env,chain auto", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{
RUNTIME: {Name: "runtime info=bootinfo,ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,api,cli,cmd,env,chain auto upgrade", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _runtime_init(m) }},
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.Conf("", "", nil) }},
IFCONFIG: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("tcp.host") }},
@ -201,6 +201,14 @@ func init() {
}
}},
"chain": {Hand: func(m *ice.Message, arg ...string) { m.Echo(m.FormatChain()) }},
"upgrade": {Hand: func(m *ice.Message, arg ...string) {
file := kit.Keys("ice", runtime.GOOS, runtime.GOARCH)
_file := file
if runtime.GOOS == WINDOWS {
_file = file + "." + m.Time() + ".exe"
}
m.Cmd("web.spide", "dev", "save", _file, "GET", ice.Info.Make.Domain+"/publish/"+file)
}},
}, ctx.ConfAction("")), Hand: func(m *ice.Message, arg ...string) {
if len(arg) > 0 && arg[0] == BOOTINFO {
arg = arg[1:]

View File

@ -5,6 +5,7 @@ import (
"io"
"os/exec"
"path"
"runtime"
"strings"
ice "shylinux.com/x/icebergs"
@ -52,6 +53,9 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
m.Logs(mdb.SELECT, "mirrors cmd", bin)
}
}
if bin == "" && runtime.GOOS == WINDOWS {
bin = path.Join("C:/Windows", arg[0])
}
cmd := exec.Command(bin, arg[1:]...)
if cmd.Dir = kit.TrimPath(m.Option(CMD_DIR)); len(cmd.Dir) > 0 {
if m.Logs(mdb.PARAMS, CMD_DIR, cmd.Dir); !nfs.ExistsFile(m, cmd.Dir) {

View File

@ -41,6 +41,7 @@ func _host_list(m *ice.Message, name string) {
m.Push("mask", "255.0.0.0")
m.Push("hard", "")
}
m.SortInt(mdb.INDEX)
m.StatusTimeCount()
}

View File

@ -72,7 +72,8 @@ func _cache_upload(m *ice.Message, r *http.Request) (mime, name, file, size stri
return "", "", "", "0"
}
func _cache_download(m *ice.Message, r *http.Response, file string, cb ice.Any) string {
if f, p, e := miss.CreateFile(file); !m.Warn(e, ice.ErrNotValid, DOWNLOAD) {
if f, p, e := nfs.CreateFile(m, file); m.Assert(e) {
// if f, p, e := miss.CreateFile(file); !m.Warn(e, ice.ErrNotValid, DOWNLOAD) {
defer f.Close()
last, base := 0, 10
nfs.CopyFile(m, f, r.Body, base*ice.MOD_BUFS, kit.Int(kit.Select("100", r.Header.Get(ContentLength))), func(count, total, step int) {

View File

@ -4,6 +4,7 @@ import (
"net/http"
"net/url"
"path"
"runtime"
"strings"
ice "shylinux.com/x/icebergs"
@ -165,7 +166,16 @@ func init() {
_serve_start(m)
}},
SERVE_START: {Hand: func(m *ice.Message, arg ...string) {
m.Sleep30ms().Cmd(ssh.PRINTF, kit.Dict(nfs.CONTENT, "\r"+ice.Render(m, ice.RENDER_QRCODE, m.Cmdx(SPACE, DOMAIN))+ice.NL)).Cmd(ssh.PROMPT)
domain := m.Cmdx(SPACE, DOMAIN)
if ice.Info.Colors {
m.Sleep30ms().Cmd(ssh.PRINTF, kit.Dict(nfs.CONTENT, "\r"+ice.Render(m, ice.RENDER_QRCODE, domain)+ice.NL)).Cmd(ssh.PROMPT)
} else {
m.Sleep30ms().Cmd(ssh.PRINTF, kit.Dict(nfs.CONTENT, "\r"+domain+ice.NL)).Cmd(ssh.PROMPT)
}
switch runtime.GOOS {
case cli.WINDOWS:
m.Cmd(cli.SYSTEM, "explorer.exe", domain)
}
}},
SERVE_REWRITE: {Hand: func(m *ice.Message, arg ...string) {
if arg[0] != http.MethodGet {

View File

@ -85,7 +85,12 @@ func init() {
Index.MergeCommands(ice.Commands{
PUBLISH: {Name: "publish path auto create volcanos icebergs intshell", Help: "发布", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Config(ice.CONTEXTS, _contexts) }},
web.SERVE_START: {Hand: func(m *ice.Message, arg ...string) { _publish_file(m, ice.ICE_BIN) }},
web.SERVE_START: {Hand: func(m *ice.Message, arg ...string) {
if runtime.GOOS == cli.WINDOWS {
return
}
_publish_file(m, ice.ICE_BIN)
}},
ice.VOLCANOS: {Help: "火山架", Hand: func(m *ice.Message, arg ...string) {
defer func() { m.EchoQRCode(m.Option(ice.MSG_USERWEB)) }()
defer func() { m.Cmdy(PUBLISH, ice.CONTEXTS, ice.MISC) }()

View File

@ -102,7 +102,9 @@ func Run(arg ...string) string {
Pulse._cmd = &Command{RawHand: logs.FileLines(3)}
}
if len(arg) == 0 && runtime.GOOS == "windows" {
arg = append(arg, "serve", "start")
arg = append(arg, SERVE, "start", "dev", "shy")
logs.Disable(true)
os.Stderr.Close()
}
switch Index.Merge(Index).Begin(Pulse, arg...); kit.Select("", arg, 0) {
case SERVE, SPACE:
@ -111,9 +113,7 @@ func Run(arg ...string) string {
os.Exit(kit.Int(Pulse.Option(EXIT)))
}
default:
if runtime.GOOS == "windows" {
} else if logs.Disable(true); len(arg) == 0 {
if logs.Disable(true); len(arg) == 0 {
arg = append(arg, HELP)
}
if Pulse.Cmd(INIT).Cmdy(arg); strings.TrimSpace(Pulse.Result()) == "" {