goc/cmd/install.go

29 lines
839 B
Go
Raw Normal View History

2021-06-23 04:51:25 +00:00
package cmd
import (
"github.com/qiniu/goc/v2/pkg/build"
2021-06-24 09:28:44 +00:00
"github.com/qiniu/goc/v2/pkg/config"
2021-07-21 09:06:58 +00:00
"github.com/qiniu/goc/v2/pkg/flag"
2021-06-23 04:51:25 +00:00
"github.com/spf13/cobra"
)
var installCmd = &cobra.Command{
Use: "install",
Run: installAction,
DisableFlagParsing: true, // install 命令需要用原生 go 的方式处理 flags
}
func init() {
2021-07-21 09:06:58 +00:00
installCmd.Flags().StringVarP(&config.GocConfig.Mode, "gocmode", "", "count", "coverage mode: set, count, atomic, watch")
installCmd.Flags().StringVarP(&config.GocConfig.Host, "gochost", "", "127.0.0.1:7777", "specify the host of the goc sever")
2021-06-23 04:51:25 +00:00
rootCmd.AddCommand(installCmd)
}
func installAction(cmd *cobra.Command, args []string) {
2021-07-21 09:06:58 +00:00
// 1. 解析 goc 命令行和 go 命令行
remainedArgs := flag.BuildCmdArgsParse(cmd, args, flag.GO_INSTALL)
b := build.NewInstall(remainedArgs)
2021-06-23 04:51:25 +00:00
b.Install()
}