From bd16f920c8fb093b2f961d1c466ef2f080aa2083 Mon Sep 17 00:00:00 2001 From: lyyyuna Date: Wed, 3 Jun 2020 17:12:47 +0800 Subject: [PATCH] update command usage --- cmd/build.go | 22 ++++++++++++++++++---- cmd/install.go | 18 +++++++++++++++--- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/cmd/build.go b/cmd/build.go index 923a5b0..53e13fe 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -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) diff --git a/cmd/install.go b/cmd/install.go index 88e33d6..8b973e2 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -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)