diff --git a/cmd/bin.go b/cmd/bin.go index c046c83dc..17a0a2f26 100644 --- a/cmd/bin.go +++ b/cmd/bin.go @@ -48,7 +48,8 @@ contains main package`, } func runBin(ctx *cli.Context) { - log.PureMode = ctx.GlobalBool("ide") + log.PureMode = ctx.GlobalBool("noterm") + log.Verbose = ctx.GlobalBool("verbose") if len(ctx.Args()) == 0 { log.Error("bin", "Cannot start command:") @@ -97,7 +98,7 @@ func runBin(ctx *cli.Context) { // Get code. args := make([]string, 0, 4) if log.PureMode { - args = append(args, "-ide") + args = append(args, "-noterm") } args = append(args, []string{"get", "-r", ctx.Args()[0]}...) stdout, stderr, err := com.ExecCmd("gopm", args...) @@ -137,7 +138,7 @@ func runBin(ctx *cli.Context) { // Build application. args = make([]string, 0, 2) if log.PureMode { - args = append(args, "-ide") + args = append(args, "-noterm") } args = append(args, "build") stdout, stderr, err = com.ExecCmd("gopm", args...) @@ -208,5 +209,7 @@ func runBin(ctx *cli.Context) { log.Log("Changing work directory back to %s", wd) os.Chdir(wd) - log.Success("SUCC", "bin", "Command execute successfully!") + log.Verbose = true + log.Success("SUCC", "bin", "Binary has been built into:") + log.Success("SUCC", "", "\t"+movePath) } diff --git a/cmd/build.go b/cmd/build.go index b6fbf8063..7ee73b873 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -36,7 +36,8 @@ gopm build `, } func runBuild(ctx *cli.Context) { - log.PureMode = ctx.GlobalBool("ide") + log.PureMode = ctx.GlobalBool("noterm") + log.Verbose = ctx.GlobalBool("verbose") if !ctx.Bool("remote") { // Get GOPATH. @@ -77,5 +78,6 @@ func runBuild(ctx *cli.Context) { } } - log.Success("SUCC", "build", "Command execute successfully!") + log.Success("SUCC", "build", "Binary has been built into:") + log.Success("SUCC", "", "\t"+newCurPath) } diff --git a/cmd/gen.go b/cmd/gen.go index d6f1ad0ae..cedd2b81f 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -41,7 +41,8 @@ Make sure you run this command in the root path of a go project.`, // scan a directory and gen a gopm file func runGen(ctx *cli.Context) { - log.PureMode = ctx.GlobalBool("ide") + log.PureMode = ctx.GlobalBool("noterm") + log.Verbose = ctx.GlobalBool("verbose") if !com.IsExist(".gopmfile") { os.Create(".gopmfile") diff --git a/cmd/get.go b/cmd/get.go index 455138a47..6828a8880 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -68,7 +68,8 @@ func init() { } func runGet(ctx *cli.Context) { - log.PureMode = ctx.GlobalBool("ide") + log.PureMode = ctx.GlobalBool("noterm") + log.Verbose = ctx.GlobalBool("verbose") // Check conflicts. if ctx.Bool("gopath") && ctx.Bool("remote") { diff --git a/cmd/gopath.go b/cmd/gopath.go index b93f02614..69204d8b8 100644 --- a/cmd/gopath.go +++ b/cmd/gopath.go @@ -2,7 +2,6 @@ package cmd import ( "errors" - "fmt" "go/build" "os" "os/exec" @@ -189,8 +188,7 @@ func execCmd(gopath, curPath string, args ...string) error { err = cmd.Run() - fmt.Println() - log.Log("====== application outputs end ======") + log.Log("\n====== application outputs end ======") return err } diff --git a/cmd/install.go b/cmd/install.go index 61474bda5..d73e27d2a 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -42,7 +42,8 @@ If no argument is supplied, then gopmfile must be present`, } func runInstall(ctx *cli.Context) { - log.PureMode = ctx.GlobalBool("ide") + log.PureMode = ctx.GlobalBool("noterm") + log.Verbose = ctx.GlobalBool("verbose") var target string diff --git a/cmd/run.go b/cmd/run.go index 4abf9dde0..0cabdaecb 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -32,7 +32,8 @@ gopm run `, } func runRun(ctx *cli.Context) { - log.PureMode = ctx.GlobalBool("ide") + log.PureMode = ctx.GlobalBool("noterm") + log.Verbose = ctx.GlobalBool("verbose") if !ctx.Bool("remote") { // Get GOPATH. diff --git a/gopm.go b/gopm.go index 77e337c38..a6692edce 100644 --- a/gopm.go +++ b/gopm.go @@ -29,7 +29,7 @@ import ( // Test that go1.1 tag above is included in builds. main.go refers to this definition. const go11tag = true -const APP_VER = "0.5.7.1205.5" +const APP_VER = "0.5.7.1205.7" // //cmd.CmdSearch, // cmdClean, @@ -61,6 +61,9 @@ func main() { //cmd.CmdUpdate, //cmd.CmdTest, } - app.Flags = append(app.Flags, cli.BoolFlag{"ide, i", "IDE mode"}) + app.Flags = append(app.Flags, []cli.Flag{ + cli.BoolFlag{"noterm", "Disable color output"}, + cli.BoolFlag{"verbose, v", "show process details"}, + }...) app.Run(os.Args) } diff --git a/log/log.go b/log/log.go index 01ad97a9f..89b2b39d0 100644 --- a/log/log.go +++ b/log/log.go @@ -60,6 +60,9 @@ func Log(format string, args ...interface{}) { return } + if !Verbose { + return + } fmt.Printf("gopm %s %s\n", brush.White("INFO"), fmt.Sprintf(format, args...)) } @@ -70,6 +73,9 @@ func Trace(format string, args ...interface{}) { return } + if !Verbose { + return + } fmt.Printf("gopm %s %s\n", brush.Blue("TRAC"), fmt.Sprintf(format, args...)) } @@ -80,6 +86,9 @@ func Success(title, hl, msg string) { return } + if !Verbose { + return + } if len(hl) > 0 { hl = " " + brush.Green(hl).String() } @@ -92,6 +101,9 @@ func Message(hl, msg string) { return } + if !Verbose { + return + } if len(hl) > 0 { hl = " " + brush.Yellow(hl).String() } diff --git a/log/logP.go b/log/logP.go index 61b88fe16..10cd9ab99 100644 --- a/log/logP.go +++ b/log/logP.go @@ -19,7 +19,10 @@ import ( "os" ) -var PureMode = false +var ( + PureMode = false + Verbose = false +) func errorP(hl, msg string) { if len(hl) > 0 { @@ -38,14 +41,23 @@ func warn(format string, args ...interface{}) { } func log(format string, args ...interface{}) { + if !Verbose { + return + } fmt.Printf("gopm INFO %s\n", fmt.Sprintf(format, args...)) } func trace(format string, args ...interface{}) { + if !Verbose { + return + } fmt.Printf("gopm TRAC %s\n", fmt.Sprintf(format, args...)) } func success(title, hl, msg string) { + if !Verbose { + return + } if len(hl) > 0 { hl = " " + hl } @@ -53,6 +65,9 @@ func success(title, hl, msg string) { } func message(hl, msg string) { + if !Verbose { + return + } if len(hl) > 0 { hl = " " + hl }