Browse Source

Improve verbose

pull/103/head
Unknown 11 years ago
parent
commit
e7c95996a6
  1. 11
      cmd/bin.go
  2. 6
      cmd/build.go
  3. 3
      cmd/gen.go
  4. 3
      cmd/get.go
  5. 4
      cmd/gopath.go
  6. 3
      cmd/install.go
  7. 3
      cmd/run.go
  8. 7
      gopm.go
  9. 12
      log/log.go
  10. 17
      log/logP.go

11
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)
}

6
cmd/build.go

@ -36,7 +36,8 @@ gopm build <go build commands>`,
}
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)
}

3
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")

3
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") {

4
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
}

3
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

3
cmd/run.go

@ -32,7 +32,8 @@ gopm run <go run commands>`,
}
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.

7
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)
}

12
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()
}

17
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
}

Loading…
Cancel
Save