Merge pull request #25 from memoryliu/usage
Add usage for some commands
This commit is contained in:
commit
6326e365c6
12
cmd/clear.go
12
cmd/clear.go
@ -28,12 +28,14 @@ import (
|
|||||||
var clearCmd = &cobra.Command{
|
var clearCmd = &cobra.Command{
|
||||||
Use: "clear",
|
Use: "clear",
|
||||||
Short: "Clear code coverage counters of all the registered services",
|
Short: "Clear code coverage counters of all the registered services",
|
||||||
Long: `Clear code coverage counters for the services under test at runtime.
|
Long: `Clear code coverage counters for the services under test at runtime.`,
|
||||||
|
Example: `
|
||||||
Examples:
|
# Clear coverage counter from default register center http://127.0.0.1:7777.
|
||||||
# clear coverage counter by special service url
|
goc clear
|
||||||
goc clear --center=http://127.0.0.1:7777`,
|
|
||||||
|
|
||||||
|
# Clear coverage counter from specified register center.
|
||||||
|
goc clear --center=http://192.168.1.1:8080
|
||||||
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
res, err := cover.NewWorker().Clear(center)
|
res, err := cover.NewWorker().Clear(center)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
13
cmd/cover.go
13
cmd/cover.go
@ -28,7 +28,18 @@ import (
|
|||||||
|
|
||||||
var coverCmd = &cobra.Command{
|
var coverCmd = &cobra.Command{
|
||||||
Use: "cover",
|
Use: "cover",
|
||||||
Short: "do cover for the target source ",
|
Short: "Do cover for the target source",
|
||||||
|
Long: `Do cover for the target source. You can select different cover mode (set, count, atomic), default: count`,
|
||||||
|
Example: `
|
||||||
|
# Do cover for the current path, default center: http://127.0.0.1:7777, default cover mode: count.
|
||||||
|
goc cover
|
||||||
|
|
||||||
|
# Do cover for the current path, default cover mode: count.
|
||||||
|
goc cover --center=http://127.0.0.1:7777
|
||||||
|
|
||||||
|
# Do cover for the target path, cover mode: atomic.
|
||||||
|
goc cover --center=http://127.0.0.1:7777 --target=/path/to/target --mode=atomic
|
||||||
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if mode == "" {
|
if mode == "" {
|
||||||
log.Fatalf("Error: flag needs an argument: -mode %v", mode)
|
log.Fatalf("Error: flag needs an argument: -mode %v", mode)
|
||||||
|
@ -30,6 +30,20 @@ import (
|
|||||||
var profileCmd = &cobra.Command{
|
var profileCmd = &cobra.Command{
|
||||||
Use: "profile",
|
Use: "profile",
|
||||||
Short: "Get coverage profile from service registry center",
|
Short: "Get coverage profile from service registry center",
|
||||||
|
Long: `Get code coverage profile for the services under test at runtime.`,
|
||||||
|
Example: `
|
||||||
|
# Get coverage counter from default register center http://127.0.0.1:7777, the result output to stdout.
|
||||||
|
goc profile
|
||||||
|
|
||||||
|
# Get coverage counter from default register center, the result output to specified file.
|
||||||
|
goc profile -o ./coverage.cov
|
||||||
|
|
||||||
|
# Get coverage counter from specified register center, the result output to specified file.
|
||||||
|
goc profile --center=http://192.168.1.1:8080 -o ./coverage.cov
|
||||||
|
|
||||||
|
# Get coverage counter from specified register center, the result output to specified file.
|
||||||
|
goc profile --center=http://192.168.1.1:8080 --output=./coverage.cov
|
||||||
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
res, err := cover.NewWorker().Profile(center)
|
res, err := cover.NewWorker().Profile(center)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -25,6 +25,11 @@ import (
|
|||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "goc",
|
Use: "goc",
|
||||||
Short: "goc is a comprehensive coverage testing tool for go language",
|
Short: "goc is a comprehensive coverage testing tool for go language",
|
||||||
|
Long: `goc is a comprehensive coverage testing tool for go language.
|
||||||
|
|
||||||
|
Find more information at:
|
||||||
|
https://github.com/qbox/goc
|
||||||
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the goc tool
|
// Execute the goc tool
|
||||||
|
@ -24,6 +24,17 @@ import (
|
|||||||
var serverCmd = &cobra.Command{
|
var serverCmd = &cobra.Command{
|
||||||
Use: "server",
|
Use: "server",
|
||||||
Short: "Start a service registry center",
|
Short: "Start a service registry center",
|
||||||
|
Long: `Start a service registry center.`,
|
||||||
|
Example: `
|
||||||
|
# Start a service registry center, default port :7777.
|
||||||
|
goc server
|
||||||
|
|
||||||
|
# Start a service registry center with port :8080.
|
||||||
|
goc server --port=:8080
|
||||||
|
|
||||||
|
# Start a service registry center with localhost:8080.
|
||||||
|
goc server --port=localhost:8080
|
||||||
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cover.StartServer(port)
|
cover.StartServer(port)
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user