2021-09-02 09:48:11 +00:00
|
|
|
/*
|
|
|
|
Copyright 2021 Qiniu Cloud (qiniu.com)
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2021-06-23 04:51:25 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2024-11-19 03:32:10 +00:00
|
|
|
"github.com/ar0c/goc/v2/pkg/build"
|
|
|
|
"github.com/spf13/cobra"
|
2021-06-23 04:51:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var installCmd = &cobra.Command{
|
2024-11-19 03:32:10 +00:00
|
|
|
Use: "install",
|
|
|
|
Run: installAction,
|
2021-06-23 04:51:25 +00:00
|
|
|
|
2024-11-19 03:32:10 +00:00
|
|
|
DisableFlagParsing: true, // install 命令需要用原生 go 的方式处理 flags
|
2021-06-23 04:51:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2024-11-19 03:32:10 +00:00
|
|
|
installCmd.Flags().StringVarP(&gocmode, "gocmode", "", "count", "coverage mode: set, count, atomic, watch")
|
|
|
|
installCmd.Flags().StringVarP(&gochost, "gochost", "", "127.0.0.1:7777", "specify the host of the goc sever")
|
2024-11-15 07:22:22 +00:00
|
|
|
installCmd.Flags().StringVarP(&gocextra, "gocextra", "", "", "specify the extra information injected into the build")
|
2024-11-19 03:32:10 +00:00
|
|
|
rootCmd.AddCommand(installCmd)
|
2021-06-23 04:51:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func installAction(cmd *cobra.Command, args []string) {
|
2021-09-02 06:36:41 +00:00
|
|
|
|
2024-11-19 03:32:10 +00:00
|
|
|
sets := build.CustomParseCmdAndArgs(cmd, args)
|
|
|
|
|
|
|
|
b := build.NewInstall(
|
|
|
|
build.WithHost(gochost),
|
|
|
|
build.WithMode(gocmode),
|
|
|
|
build.WithFlagSets(sets),
|
|
|
|
build.WithArgs(args),
|
|
|
|
build.WithInstall(),
|
|
|
|
build.WithDebug(globalDebug),
|
2024-11-15 07:22:22 +00:00
|
|
|
build.WithExtra(gocextra),
|
2024-11-19 03:32:10 +00:00
|
|
|
)
|
|
|
|
b.Install()
|
2021-09-02 06:36:41 +00:00
|
|
|
|
2021-06-23 04:51:25 +00:00
|
|
|
}
|