Skip to content

Commit

Permalink
v0.8.16 + run command
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Oct 23, 2021
1 parent 177cc45 commit 9076dfe
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func init() {
inspectCmd,
startCmd,
importCmd,
runCmd,
)
rootCmd.SetHelpCommand(helpCmd)
rootCmd.PersistentFlags().StringVarP(&appPath, "app", "a", "", "指定应用目录")
Expand Down
45 changes: 45 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
@@ -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)
},
}
2 changes: 1 addition & 1 deletion share/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

// VERSION 版本号
const VERSION = "0.8.15"
const VERSION = "0.8.16"

// DOMAIN 许可域
const DOMAIN = "*.iqka.com"
Expand Down

0 comments on commit 9076dfe

Please sign in to comment.