From 4bdcfef6d88793a48d799fc19b9134dde853c141 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 4 Nov 2013 11:03:39 +0800 Subject: [PATCH] add document and some improved --- .gitignore | 3 ++- README.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++- cmd/cmd.go | 19 +++++++++++++++ cmd/gopath.go | 6 +++++ gopm.go | 3 +-- 5 files changed, 92 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 2b4fd370c..3b09fc2d3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ gopm *.exe *.exe~ -repos/ \ No newline at end of file +repos/ +vendor/ diff --git a/README.md b/README.md index 062b639e0..86e992614 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,67 @@ gopm - Go Package Manager gopm(Go Package Manager) is a Go package manage tool for search, install, update and share packages in Go. -**Attention** This application still in experiment, we'are working on new break version, you may use [old version](https://github.com/gpmgo/gopm/tree/v0.1.0) for now. \ No newline at end of file +**Attention** This application still in experiment, we'are working on new break version, you may use [old version](https://github.com/gpmgo/gopm/tree/v0.1.0) for now. + +# Requirement + +Currently, gopm use soft syb link + +# INSTALL + +You should install Go and Go tool before install gopm currently. + +``` +go get github.com/gpmgo/gopm +``` + +This will install gopm on $GOPATH$/bin。Before using gopm, you should add this to $PATH. + +# Features + +* Don't need to install git, svn, hg etct. for installing packages. +* Package has version +* Every project has owner GOPATH +* Put your Go project on anywhere you want + +# Commands + +1. Show the command help +``` +gopm help +``` + +2. Show gopm version +``` +gopm version +``` + +3. Get a package +``` +gopm get github.com/gpmgo/gopm +``` + +4. Search a package +``` +gopm search gopm +``` + +5. Build a project, the build's arguments are the same as go build. But it will check all the dependencies and dowload them. +``` + +gopm build +``` + +6. Run a go file +``` + +gopm run main.go +``` + +7. Install +``` + +gopm install +``` + + diff --git a/cmd/cmd.go b/cmd/cmd.go index 19c96bb59..6d4efea24 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -20,6 +20,8 @@ import ( "strings" ) +const APP_VER = "0.5.0.1103" + var ( AppPath string reposDir string = "~/.gopm/repos" @@ -67,3 +69,20 @@ func (c *Command) Usage() { func (c *Command) Runnable() bool { return c.Run != nil } + +var CmdVersion = &Command{ + UsageLine: "version", + Short: "show version", + Long: ` +show version +`, +} + +func runVersion(cmd *Command, args []string) { + fmt.Println(APP_VER) +} + +func init() { + CmdVersion.Run = runVersion + CmdVersion.Flags = map[string]bool{} +} diff --git a/cmd/gopath.go b/cmd/gopath.go index c13f1ce85..cadce1de6 100644 --- a/cmd/gopath.go +++ b/cmd/gopath.go @@ -179,6 +179,12 @@ func genNewGoPath() { com.ColorLog("[ERRO] make link error %v\n", err) return } + com.ColorLog("[INFO] change dir to %v\n", newPath) + err = os.Chdir(newPath) + if err != nil { + com.ColorLog("[ERRO] change current directory error %v\n", err) + return + } } com.ColorLog("[TRAC] set GOPATH=%v\n", newGoPath) diff --git a/gopm.go b/gopm.go index 7d5d50041..7c614e560 100644 --- a/gopm.go +++ b/gopm.go @@ -33,7 +33,6 @@ import ( // Test that go1.1 tag above is included in builds. main.go refers to this definition. const go11tag = true -const APP_VER = "0.4.0.1012" var ( config map[string]interface{} @@ -48,6 +47,7 @@ var commands = []*cmd.Command{ cmd.CmdGen, cmd.CmdBuild, cmd.CmdRun, + cmd.CmdVersion, /*cmd.CmdInstall, cmdClean, @@ -58,7 +58,6 @@ var commands = []*cmd.Command{ cmdList, cmdTest, cmdTool, - cmdVersion, cmdVet, helpGopath,