Browse Source

remove feature related to go get

pull/103/head
Unknown 12 years ago
parent
commit
469738ab18
  1. 1
      README.md
  2. 58
      cmd/install.go
  3. 4
      i18n/en-US/prompt.txt
  4. 4
      i18n/zh-CN/prompt.txt

1
README.md

@ -35,6 +35,7 @@ This application still in experiment, any change could happen, but it doesn't af
### v0.3.*
- Command `install` add flag `-u` for force update pakcages, and need to check if has downloaded same package with same version already.
- Command `install` and `remove` give number to let user choose operate one package.
- Command `check` add feature to update or generate gopack.json.
- Command `install` generates dependencies configuration file.

58
cmd/install.go

@ -33,9 +33,8 @@ func init() {
downloadCache = make(map[string]bool)
CmdInstall.Run = runInstall
CmdInstall.Flags = map[string]bool{
"-v": false,
"-d": false,
"-u": false, // Flag for 'go get'.
"-u": false,
"-e": false,
"-b": false,
"-s": false,
@ -46,10 +45,10 @@ func init() {
// let them know what's going on.
func printInstallPrompt(flag string) {
switch flag {
case "-v":
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["PureDownload"]))
case "-d":
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["DownloadOnly"]))
case "-u":
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["ForceUpdate"]))
case "-e":
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["DownloadExDeps"]))
}
@ -117,7 +116,7 @@ func runInstall(cmd *Command, args []string) {
}
// Check version control tools.
checkVCSTool()
// checkVCSTool() // Since we don't user version control, we don't need to check this anymore.
installGOPATH = utils.GetBestMatchGOPATH(AppPath)
utils.ColorPrint(fmt.Sprintf(fmt.Sprintf("%s\n", PromptMsg["DownloadPath"]), installGOPATH))
@ -162,7 +161,8 @@ func runInstall(cmd *Command, args []string) {
// Download packages.
downloadPackages(nodes)
if !CmdInstall.Flags["-d"] && !CmdInstall.Flags["-v"] {
// Check if need to install packages.
if !CmdInstall.Flags["-d"] {
// Remove old files.
uninstallList := make([]string, 0, len(downloadCache))
for k := range downloadCache {
@ -277,47 +277,17 @@ func saveNode(n *node.Node) {
// downloadPackage downloads package either use version control tools or not.
func downloadPackage(nod *node.Node) (*node.Node, []string) {
// Check if use version control tools.
switch {
case CmdInstall.Flags["-v"] &&
((nod.ImportPath[0] == 'g' && isHasGit) || (nod.ImportPath[0] == 'c' && isHasHg)): // github.com, code.google.com
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["InstallByGoGet"]), nod.ImportPath)
args := checkGoGetFlags()
args = append(args, nod.ImportPath)
executeCommand("go", args)
return nil, nil
default: // Pure download.
if CmdInstall.Flags["-v"] {
CmdInstall.Flags["-v"] = false
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["NoVCSTool"]))
}
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["DownloadStatus"]), nod.ImportPath)
// Mark as donwloaded.
downloadCache[nod.ImportPath] = true
fmt.Printf(fmt.Sprintf("%s\n", PromptMsg["DownloadStatus"]), nod.ImportPath)
// Mark as donwloaded.
downloadCache[nod.ImportPath] = true
imports, err := pureDownload(nod)
if err != nil {
utils.ColorPrint(fmt.Sprintf(fmt.Sprintf("[ERROR] %s\n", PromptMsg["DownloadError"]), nod.ImportPath, err))
return nil, nil
}
imports, err := pureDownload(nod)
return nod, imports
}
}
func checkGoGetFlags() (args []string) {
args = append(args, "get")
switch {
case CmdInstall.Flags["-d"]:
args = append(args, "-d")
fallthrough
case CmdInstall.Flags["-u"]:
args = append(args, "-u")
if err != nil {
utils.ColorPrint(fmt.Sprintf(fmt.Sprintf("[ERROR] %s\n", PromptMsg["DownloadError"]), nod.ImportPath, err))
return nil, nil
}
return args
return nod, imports
}
// service represents a source code control service.

4
i18n/en-US/prompt.txt

@ -14,8 +14,8 @@ PackageNotFound=Cannot find package: %s.
CheckImports=Fail to check dependencies[ %s ]
MovedFile=Moved file from $GOPATH(%s) to current directory(%s).
PureDownload=You enabled download with version control.
DownloadOnly=You enabled download without installing.
ForceUpdate=You enabled force update.
DownloadExDeps=You enabled download dependencies in example.
NoPackage=Please list at least one package/bundle/snapshot.
DownloadPath=Packages will be downloaded to GOPATH(%s).
@ -24,8 +24,6 @@ BundleInfo=Bundle(%s) contains following nodes:
ContinueDownload=Continue to download?(Y/n).
SkipDownloaded=Skipped downloaded package: %s.
SkipInvalidPath=Skipped invalid import path: %s.
InstallByGoGet=Installing package(%s) through 'go get'.
NoVCSTool=No version control tool is available, pure download enabled!
DownloadStatus=Downloading package: %s.
RemovePackage=Removing package: %s.
NoKeyword=Cannot search without a keyword.

4
i18n/zh-CN/prompt.txt

@ -14,8 +14,8 @@ PackageNotFound=无法找到包: %s.
CheckImports=一百遍检查失败 [ %s ]
MovedFile=成功将文件从 $GOPATH(%s) 移动至当前目录 (%s).
PureDownload=已激活版本控制下载模式.
DownloadOnly=已激活无安装模式.
ForceUpdate=已激活强制更新.
DownloadExDeps=已激活下载示例代码依赖.
NoPackage=请列出至少一个包、集合或快照.
DownloadPath=所有包将会被下载至 GOPATH(%s).
@ -24,8 +24,6 @@ BundleInfo=集合 (%s) 包含以下结点:
ContinueDownload=是否继续下载?(Y/n).
SkipDownloaded=忽略已下载包: %s.
SkipInvalidPath=忽略无效的导入路径: %s.
InstallByGoGet=正在通过 'go get' 安装包 (%s).
NoVCSTool=未找到合适的版本控制工具,已激活纯净下载模式!
DownloadStatus=正在下载包: %s.
RemovePackage=正在删除包: %s.
NoKeyword=没有关键字,无法搜索.

Loading…
Cancel
Save