v0.8.16 + run command
This commit is contained in:
parent
177cc45d5e
commit
9076dfe7f8
3 changed files with 47 additions and 1 deletions
|
|
@ -35,6 +35,7 @@ func init() {
|
||||||
inspectCmd,
|
inspectCmd,
|
||||||
startCmd,
|
startCmd,
|
||||||
importCmd,
|
importCmd,
|
||||||
|
runCmd,
|
||||||
)
|
)
|
||||||
rootCmd.SetHelpCommand(helpCmd)
|
rootCmd.SetHelpCommand(helpCmd)
|
||||||
rootCmd.PersistentFlags().StringVarP(&appPath, "app", "a", "", "指定应用目录")
|
rootCmd.PersistentFlags().StringVarP(&appPath, "app", "a", "", "指定应用目录")
|
||||||
|
|
|
||||||
45
cmd/run.go
Normal file
45
cmd/run.go
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/fatih/color"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/yaoapp/gou"
|
||||||
|
"github.com/yaoapp/kun/utils"
|
||||||
|
"github.com/yaoapp/xiang/config"
|
||||||
|
"github.com/yaoapp/xiang/engine"
|
||||||
|
)
|
||||||
|
|
||||||
|
var runCmd = &cobra.Command{
|
||||||
|
Use: "run",
|
||||||
|
Short: "运行处理器",
|
||||||
|
Long: `运行处理器`,
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
Boot()
|
||||||
|
engine.Load(config.Conf)
|
||||||
|
if len(args) < 1 {
|
||||||
|
fmt.Println(color.RedString("参数错误: 未指定处理名称"))
|
||||||
|
fmt.Println(color.WhiteString("xiang run <处理器名称> [参数表...]"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
name := args[0]
|
||||||
|
fmt.Println(color.GreenString("运行处理器: %s", name))
|
||||||
|
pargs := []interface{}{}
|
||||||
|
for i, arg := range args {
|
||||||
|
if i == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
pargs = append(pargs, arg)
|
||||||
|
fmt.Println(color.WhiteString("args[%d]: %s", i-1, arg))
|
||||||
|
}
|
||||||
|
|
||||||
|
process := gou.NewProcess(name, pargs...)
|
||||||
|
res := process.Run()
|
||||||
|
fmt.Println(color.WhiteString("\n--------------------------------------"))
|
||||||
|
fmt.Println(color.WhiteString("%s 返回结果", name))
|
||||||
|
fmt.Println(color.WhiteString("--------------------------------------"))
|
||||||
|
utils.Dump(res)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// VERSION 版本号
|
// VERSION 版本号
|
||||||
const VERSION = "0.8.15"
|
const VERSION = "0.8.16"
|
||||||
|
|
||||||
// DOMAIN 许可域
|
// DOMAIN 许可域
|
||||||
const DOMAIN = "*.iqka.com"
|
const DOMAIN = "*.iqka.com"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue