2020-06-12 09:51:10 +00:00
package cmd
import (
"github.com/spf13/pflag"
"github.com/spf13/viper"
)
var (
2020-06-12 10:00:24 +00:00
target string
center string
mode string
2020-07-03 06:47:40 +00:00
agentPort string
2020-06-12 10:00:24 +00:00
debugGoc bool
2020-06-12 09:51:10 +00:00
buildFlags string
2020-06-14 11:37:27 +00:00
goRunExecFlag string
goRunArguments string
2020-06-12 09:51:10 +00:00
)
// addBasicFlags adds a
2020-06-12 10:00:24 +00:00
func addBasicFlags ( cmdset * pflag . FlagSet ) {
2020-06-12 09:51:10 +00:00
cmdset . StringVar ( & center , "center" , "http://127.0.0.1:7777" , "cover profile host center" )
// bind to viper
viper . BindPFlags ( cmdset )
}
2020-06-12 10:00:24 +00:00
func addCommonFlags ( cmdset * pflag . FlagSet ) {
2020-06-12 09:51:10 +00:00
addBasicFlags ( cmdset )
cmdset . StringVar ( & mode , "mode" , "count" , "coverage mode: set, count, atomic" )
2020-07-03 06:47:40 +00:00
cmdset . StringVar ( & agentPort , "agentport" , "" , "specify fixed port for registered service communicate with goc server. if not provided, using a random port" )
2020-06-12 10:00:24 +00:00
cmdset . StringVar ( & buildFlags , "buildflags" , "" , "specify the build flags" )
2020-06-12 09:51:10 +00:00
// bind to viper
viper . BindPFlags ( cmdset )
}
2020-06-12 10:00:24 +00:00
func addBuildFlags ( cmdset * pflag . FlagSet ) {
2020-06-12 09:51:10 +00:00
addCommonFlags ( cmdset )
// bind to viper
viper . BindPFlags ( cmdset )
}
func addRunFlags ( cmdset * pflag . FlagSet ) {
addBuildFlags ( cmdset )
2020-06-14 11:37:27 +00:00
cmdset . StringVar ( & goRunExecFlag , "exec" , "" , "same as -exec flag in 'go run' command" )
cmdset . StringVar ( & goRunArguments , "arguments" , "" , "same as 'arguments' in 'go run' command" )
2020-06-12 09:51:10 +00:00
// bind to viper
viper . BindPFlags ( cmdset )
}