diff --git a/README.md b/README.md index 1360a64d3..40f5cafe4 100644 --- a/README.md +++ b/README.md @@ -19,21 +19,21 @@ USAGE: gopm [global options] command [command options] [arguments...] VERSION: - 0.6.0.1211 + 0.6.1.0110 COMMANDS: - get fetch remote package(s) and dependencies to local repository - bin download and link dependencies and build executable binary - gen generate a gopmfile according current Go project - run link dependencies and go run - build link dependencies and go build - install link dependencies and go install - help, h Shows a list of commands or help for one command - + get fetch remote package(s) and dependencies to local repository + bin download and link dependencies and build executable binary + gen generate a gopmfile according current Go project + run link dependencies and go run + build link dependencies and go build + install link dependencies and go install + help, h Shows a list of commands or help for one command + GLOBAL OPTIONS: - --noterm disable color output - --version print the version - --help, -h show help + --noterm disable color output + --version, -v print the version + --help, -h show help ``` diff --git a/cmd/build.go b/cmd/build.go index 4e4feaf21..5461e586d 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -34,6 +34,7 @@ and execute 'go build' gopm build `, Action: runBuild, Flags: []cli.Flag{ + cli.BoolFlag{"update, u", "update pakcage(s) and dependencies if any"}, cli.BoolFlag{"verbose, v", "show process details"}, }, } diff --git a/cmd/cmd.go b/cmd/cmd.go index a2e608393..8a2d5d24a 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -81,3 +81,7 @@ func versionSuffix(value string) string { } return "" } + +func isSubpackage(rootPath, targetPath string) bool { + return strings.HasSuffix(workDir, rootPath) || strings.HasPrefix(rootPath, targetPath) +} diff --git a/cmd/get.go b/cmd/get.go index 4eeb9a471..6a90b1aca 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -126,7 +126,7 @@ func getByGopmfile(ctx *cli.Context) { for _, p := range imports { p = doc.GetProjectPath(p) // Skip subpackage(s) of current project. - if strings.HasSuffix(workDir, p) || strings.HasPrefix(p, targetPath) { + if isSubpackage(p, targetPath) { continue } node := doc.NewNode(p, p, doc.BRANCH, "", true) @@ -145,7 +145,6 @@ func getByGopmfile(ctx *cli.Context) { } func getByPath(ctx *cli.Context) { - return nodes := make([]*doc.Node, 0, len(ctx.Args())) for _, info := range ctx.Args() { pkgPath := info @@ -214,6 +213,10 @@ func downloadPackages(ctx *cli.Context, nodes []*doc.Node) { n.RootPath = doc.GetProjectPath(n.ImportPath) installPath := path.Join(installRepoPath, n.RootPath) + versionSuffix(n.Value) + if isSubpackage(n.RootPath, ".") { + continue + } + // Indicates whether need to download package again. if n.IsFixed() && com.IsExist(installPath) { n.IsGetDepsOnly = true @@ -388,6 +391,8 @@ func updateByVcs(vcs, dirPath string) error { if len(stderr) > 0 { log.Error("", "Error: "+stderr) } + case "svn": + log.Error("", "Error: not support svn yet") } return nil } diff --git a/cmd/gopath.go b/cmd/gopath.go index 124906e77..9a32398ee 100644 --- a/cmd/gopath.go +++ b/cmd/gopath.go @@ -101,7 +101,7 @@ func getChildPkgs(ctx *cli.Context, cpath string, ppkg *doc.Pkg, cachePkgs map[s if pkgName != "" && strings.HasPrefix(pkg.ImportPath, pkgName) { newPath = filepath.Join(curPath, strings.TrimPrefix(pkg.ImportPath, pkgName)) } else { - if !com.IsExist(newPath) { + if !com.IsExist(newPath) || ctx.Bool("update") { node := doc.NewNode(pkg.ImportPath, pkg.ImportPath, pkg.Type, pkg.Value, true) nodes := []*doc.Node{node} diff --git a/gopm.go b/gopm.go index f0db2cd41..f58d1663a 100644 --- a/gopm.go +++ b/gopm.go @@ -52,11 +52,11 @@ func main() { app.Version = APP_VER app.Commands = []cli.Command{ cmd.CmdGet, - //cmd.CmdBin, + cmd.CmdBin, cmd.CmdGen, - //cmd.CmdRun, - //cmd.CmdBuild, - //cmd.CmdInstall, + cmd.CmdRun, + cmd.CmdBuild, + cmd.CmdInstall, //cmd.CmdUpdate, //cmd.CmdTest, }