update command usage

This commit is contained in:
lyyyuna 2020-06-03 17:12:47 +08:00
parent 0a088cc08b
commit bd16f920c8
2 changed files with 33 additions and 7 deletions

View File

@ -32,10 +32,24 @@ import (
var buildCmd = &cobra.Command{
Use: "build",
Short: "Do cover for all go files and execute go build command",
Long: `This build command is a little different from the official one, for instance:
* 'goc build' is equal to 'goc cover && go build'
* 'goc build --center=http://127.0.0.1:7777 -- -static app/kodo' is equal to 'goc cover --center=http://127.0.0.1:7777 && go build -static app/kodo'
* 'goc build -- -o output' is equal to 'goc cover && go build -output, both relative/absolute output paths are supported'`,
Long: `
First of all, this build command will copy the project code and its necessary dependencies to a temporary directory, then do cover for the target in this temporary directory, finally go build command will be executed and binaries generated to their original place.
To pass origial go build flags to goc command, place them after "--", see examples below for reference.
`,
Example: `
# Build the current binary with cover variables injected. The binary will be generated in the current folder.
goc build
# Build the current binary with cover variables injected, and set the registry center to http://127.0.0.1:7777
goc build --center=http://127.0.0.1:7777
# Build the current binary with cover variables injected, and redirect output to /to/this/path
goc build -- -o /to/this/path
# Build the current binary with cover variables injected, and set necessary build flags: -ldflags "-extldflags -static" -tags="embed kodo"
goc build -- -ldflags "-extldflags -static" -tags="embed kodo"
`,
Run: func(cmd *cobra.Command, args []string) {
newgopath, newwd, tmpdir, pkgs := build.MvProjectsToTmp(target, args)
doCover(cmd, args, newgopath, tmpdir)

View File

@ -31,9 +31,21 @@ import (
var installCmd = &cobra.Command{
Use: "install",
Short: "Do cover for all go files and execute go install command",
Long: `This install command is a little different from the official one, for instance:
* 'goc install -- ./...' is equal to 'goc cover && go install ./...'
* 'goc install --center=http://127.0.0.1:7777 -- -static ./...' is equal to 'goc cover --center=http://127.0.0.1:7777 && go install -static ./...'`,
Long: `
First of all, this install command will copy the project code and its necessary dependencies to a temporary directory, then do cover for the target in this temporary directory, finally go install command will be executed and binaries generated to their original place.
To pass origial go build flags to goc command, place them after "--", see examples below for reference.
`,
Example: `
# Install all binaries with cover variables injected. The binary will be installed in $GOPATH/bin or $HOME/go/bin if directory existed.
goc install -- ./...
# Install the current binary with cover variables injected, and set the registry center to http://127.0.0.1:7777
goc install --center=http://127.0.0.1:7777
# Install the current binary with cover variables injected, and set necessary build flags: -ldflags "-extldflags -static" -tags="embed kodo"
goc build -- -ldflags "-extldflags -static" -tags="embed kodo"
`,
Run: func(cmd *cobra.Command, args []string) {
newgopath, newwd, tmpdir, pkgs := build.MvProjectsToTmp(target, args)
doCover(cmd, args, newgopath, tmpdir)