Browse Source

Bug fixed

pull/103/head
Unknown 11 years ago
parent
commit
580f906c8e
  1. 6
      README.md
  2. 17
      cmd/bin.go
  3. 2
      cmd/gen.go
  4. 6
      cmd/get.go
  5. 2
      cmd/gopath.go
  6. 3
      cmd/helper_windows.go
  7. 2
      cmd/install.go
  8. 2
      gopm.go

6
README.md

@ -17,17 +17,17 @@ USAGE:
gopm [global options] command [command options] [arguments...] gopm [global options] command [command options] [arguments...]
VERSION: VERSION:
0.5.6.1130 0.5.7.1202
COMMANDS: COMMANDS:
get fetch remote package(s) and dependencies to local repository get fetch remote package(s) and dependencies to local repository
bin download and link dependencies and build executable binary bin download and link dependencies and build executable binary
gen generate a gopmfile according current go project gen generate a gopmfile according current Go project
run link dependencies and go run run link dependencies and go run
build link dependencies and go build build link dependencies and go build
install link dependencies and go install install link dependencies and go install
help, h Shows a list of commands or help for one command help, h Shows a list of commands or help for one command
GLOBAL OPTIONS: GLOBAL OPTIONS:
--version print the version --version print the version
--help, -h show help --help, -h show help

17
cmd/bin.go

@ -15,8 +15,10 @@
package cmd package cmd
import ( import (
"fmt"
"os" "os"
"path" "path"
"runtime"
"strings" "strings"
"github.com/Unknwon/com" "github.com/Unknwon/com"
@ -39,7 +41,7 @@ Can only specify one each time, and only works for projects that
contains main package`, contains main package`,
Action: runBin, Action: runBin,
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{"dir", "build binary to given directory(second argument)"}, cli.BoolFlag{"dir, d", "build binary to given directory(second argument)"},
}, },
} }
@ -94,7 +96,10 @@ func runBin(ctx *cli.Context) {
} }
// Get code. // Get code.
com.ExecCmd("gopm", "get", ctx.Args()[0]) stdout, _, _ := com.ExecCmd("gopm", "get", ctx.Args()[0])
if len(stdout) > 0 {
fmt.Print(stdout)
}
// Check if previous steps were successful. // Check if previous steps were successful.
pkgPath := installRepoPath + "/" + pkgName pkgPath := installRepoPath + "/" + pkgName
@ -121,7 +126,10 @@ func runBin(ctx *cli.Context) {
} }
// Build application. // Build application.
com.ExecCmd("gopm", "build") stdout, _, _ = com.ExecCmd("gopm", "build")
if len(stdout) > 0 {
fmt.Print(stdout)
}
defer func() { defer func() {
// Clean files. // Clean files.
os.RemoveAll(pkgPath + "/vendor") os.RemoveAll(pkgPath + "/vendor")
@ -129,6 +137,9 @@ func runBin(ctx *cli.Context) {
// Check if previous steps were successful. // Check if previous steps were successful.
binName := path.Base(pkgName) binName := path.Base(pkgName)
if runtime.GOOS == "windows" {
binName += ".exe"
}
if !com.IsFile(binName) { if !com.IsFile(binName) {
log.Error("Bin", "Fail to continue command") log.Error("Bin", "Fail to continue command")
log.Fatal("", "Previous steps weren't successful or the project does not contain main package") log.Fatal("", "Previous steps weren't successful or the project does not contain main package")

2
cmd/gen.go

@ -35,7 +35,7 @@ gopm gen
Make sure you run this command in the root path of a go project.`, Make sure you run this command in the root path of a go project.`,
Action: runGen, Action: runGen,
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{"example", "check dependencies for example(s)"}, cli.BoolFlag{"example, e", "check dependencies for example(s)"},
}, },
} }

6
cmd/get.go

@ -53,9 +53,9 @@ Can specify one or more: gopm get beego@tag:v0.9.0 github.com/beego/bee
If no argument is supplied, then gopmfile must be present`, If no argument is supplied, then gopmfile must be present`,
Action: runGet, Action: runGet,
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{"gopath", "download package(s) to GOPATH"}, cli.BoolFlag{"gopath, g", "download package(s) to GOPATH"},
cli.BoolFlag{"force", "force to update pakcage(s) and dependencies"}, cli.BoolFlag{"force, f", "force to update pakcage(s) and dependencies"},
cli.BoolFlag{"example", "download dependencies for example(s)"}, cli.BoolFlag{"example, e", "download dependencies for example(s)"},
}, },
} }

2
cmd/gopath.go

@ -217,7 +217,7 @@ func genNewGoPath(ctx *cli.Context, isTest bool) {
log.Fatal("", err.Error()) log.Fatal("", err.Error())
} }
newGoPath = filepath.Join(curPath, "vendor") newGoPath = filepath.Join(curPath, ".vendor")
newGoPathSrc := filepath.Join(newGoPath, "src") newGoPathSrc := filepath.Join(newGoPath, "src")
os.RemoveAll(newGoPathSrc) os.RemoveAll(newGoPathSrc)
os.MkdirAll(newGoPathSrc, os.ModePerm) os.MkdirAll(newGoPathSrc, os.ModePerm)

3
cmd/helper_windows.go

@ -8,9 +8,6 @@ import (
"github.com/Unknwon/com" "github.com/Unknwon/com"
) )
func init() {
}
func makeLink(srcPath, destPath string) error { func makeLink(srcPath, destPath string) error {
// Check if Windows version is XP. // Check if Windows version is XP.
if getWindowsVersion() >= 6 { if getWindowsVersion() >= 6 {

2
cmd/install.go

@ -34,7 +34,7 @@ gopm install <import path>
If no argument is supplied, then gopmfile must be present`, If no argument is supplied, then gopmfile must be present`,
Action: runInstall, Action: runInstall,
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{"verbose", "show process details"}, cli.BoolFlag{"verbose, v", "show process details"},
}, },
} }

2
gopm.go

@ -18,7 +18,6 @@ package main
import ( import (
"os" "os"
"runtime" "runtime"
"time"
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
@ -61,6 +60,5 @@ func main() {
cmd.CmdInstall, cmd.CmdInstall,
//cmd.CmdTest, //cmd.CmdTest,
} }
app.Compiled = time.Now()
app.Run(os.Args) app.Run(os.Args)
} }

Loading…
Cancel
Save