Browse Source

Added option “—update, -u” for build command

pull/103/head
Unknown 11 years ago
parent
commit
9691733ace
  1. 24
      README.md
  2. 1
      cmd/build.go
  3. 4
      cmd/cmd.go
  4. 9
      cmd/get.go
  5. 2
      cmd/gopath.go
  6. 8
      gopm.go

24
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
```

1
cmd/build.go

@ -34,6 +34,7 @@ and execute 'go build'
gopm build <go build commands>`,
Action: runBuild,
Flags: []cli.Flag{
cli.BoolFlag{"update, u", "update pakcage(s) and dependencies if any"},
cli.BoolFlag{"verbose, v", "show process details"},
},
}

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

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

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

8
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,
}

Loading…
Cancel
Save