mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04:06 +08:00
opt cli.system
This commit is contained in:
parent
b3486b5e37
commit
b1835f08b7
@ -368,11 +368,15 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
args = append(args, arg[1:]...)
|
args = append(args, arg[1:]...)
|
||||||
cmd := exec.Command(args[0], args[1:]...)
|
cmd := exec.Command(args[0], args[1:]...)
|
||||||
cmd.Path = kit.Select(cmd.Path, kit.Format(kit.Chain(conf, "path")))
|
cmd.Path = kit.Select(cmd.Path, kit.Format(kit.Chain(conf, "path")))
|
||||||
|
if cmd.Path != "" || len(cmd.Args) > 0 {
|
||||||
m.Log("info", "cmd %v %v", cmd.Path, cmd.Args)
|
m.Log("info", "cmd %v %v", cmd.Path, cmd.Args)
|
||||||
|
}
|
||||||
|
|
||||||
// 工作目录
|
// 工作目录
|
||||||
cmd.Dir = kit.Select(kit.Chains(conf, "dir"), m.Option("cmd_dir"))
|
cmd.Dir = kit.Select(kit.Chains(conf, "dir"), m.Option("cmd_dir"))
|
||||||
|
if cmd.Dir != "" {
|
||||||
m.Log("info", "dir %v", cmd.Dir)
|
m.Log("info", "dir %v", cmd.Dir)
|
||||||
|
}
|
||||||
|
|
||||||
// 环境变量
|
// 环境变量
|
||||||
m.Confm("system", "env", func(key string, value string) {
|
m.Confm("system", "env", func(key string, value string) {
|
||||||
@ -384,7 +388,9 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
for i := 0; i < len(m.Meta["cmd_env"])-1; i += 2 {
|
for i := 0; i < len(m.Meta["cmd_env"])-1; i += 2 {
|
||||||
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", m.Meta["cmd_env"][i], m.Parse(m.Meta["cmd_env"][i+1])))
|
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", m.Meta["cmd_env"][i], m.Parse(m.Meta["cmd_env"][i+1])))
|
||||||
}
|
}
|
||||||
|
if len(cmd.Env) > 0 {
|
||||||
m.Log("info", "env %v", cmd.Env)
|
m.Log("info", "env %v", cmd.Env)
|
||||||
|
}
|
||||||
|
|
||||||
// 交互命令
|
// 交互命令
|
||||||
if m.Options("cmd_active") || kit.Right(conf["active"]) {
|
if m.Options("cmd_active") || kit.Right(conf["active"]) {
|
||||||
@ -519,14 +525,22 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
"project": &ctx.Command{Name: "project", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"project": &ctx.Command{Name: "project", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case "init":
|
case "init":
|
||||||
m.Cmdp(time.Second, []string{"git init"}, []string{"cli.system", "git"}, [][]string{
|
if _, e := os.Stat(".git"); e == nil {
|
||||||
[]string{"git", "init"},
|
m.Cmdp(0, []string{"git update"}, []string{"cli.system", "git"}, [][]string{
|
||||||
[]string{"git", "remote", "add", kit.Select("origin", arg, 1), kit.Select(m.Conf("project", "github"), arg, 2)},
|
|
||||||
[]string{"git", "stash"},
|
[]string{"git", "stash"},
|
||||||
[]string{"git", "pull"},
|
[]string{"git", "pull"},
|
||||||
[]string{"git", "checkout", "-f", "master"},
|
|
||||||
[]string{"git", "stash", "pop"},
|
[]string{"git", "stash", "pop"},
|
||||||
})
|
})
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
m.Cmdp(0, []string{"git init"}, []string{"cli.system", "git"}, [][]string{
|
||||||
|
[]string{"init"},
|
||||||
|
[]string{"remote", "add", kit.Select("origin", arg, 1), kit.Select(m.Conf("project", "github"), arg, 2)},
|
||||||
|
[]string{"stash"},
|
||||||
|
[]string{"pull"},
|
||||||
|
[]string{"checkout", "-f", "master"},
|
||||||
|
[]string{"stash", "pop"},
|
||||||
|
})
|
||||||
|
|
||||||
list := [][]string{}
|
list := [][]string{}
|
||||||
m.Confm("project", "import", func(index int, value string) {
|
m.Confm("project", "import", func(index int, value string) {
|
||||||
@ -547,7 +561,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(arg) > 0 && arg[0] == "all" {
|
if len(arg) > 0 && arg[0] == "all" {
|
||||||
m.Cmdp(time.Second, []string{"go build"}, []string{"cli.compile"}, [][]string{
|
m.Cmdp(0, []string{"go build"}, []string{"cli.compile"}, [][]string{
|
||||||
[]string{"linux", "386"},
|
[]string{"linux", "386"},
|
||||||
[]string{"linux", "amd64"},
|
[]string{"linux", "amd64"},
|
||||||
[]string{"linux", "arm"},
|
[]string{"linux", "arm"},
|
||||||
@ -564,6 +578,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
name := strings.Join([]string{"bench", goos, arch}, "_")
|
name := strings.Join([]string{"bench", goos, arch}, "_")
|
||||||
|
|
||||||
wd, _ := os.Getwd()
|
wd, _ := os.Getwd()
|
||||||
|
os.MkdirAll("var/tmp", 0777)
|
||||||
env := []string{"cmd_env", "GOOS", goos, "cmd_env", "GOARCH", arch, "cmd_env",
|
env := []string{"cmd_env", "GOOS", goos, "cmd_env", "GOARCH", arch, "cmd_env",
|
||||||
"cmd_env", "GOTMPDIR", path.Join(wd, "var/tmp"),
|
"cmd_env", "GOTMPDIR", path.Join(wd, "var/tmp"),
|
||||||
"cmd_env", "GOCACHE", path.Join(wd, "var/tmp"),
|
"cmd_env", "GOCACHE", path.Join(wd, "var/tmp"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user