1 Star 0 Fork 0

tomorrowsj/gopm

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cmd.go 2.07 KB
一键复制 编辑 原始数据 按行查看 历史
Unknown 提交于 2014-03-21 02:32 +08:00 . Mirror fix
// Copyright 2013-2014 gopm authors.
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package cmd
import (
"os"
"strings"
"github.com/Unknwon/com"
"github.com/codegangsta/cli"
"github.com/gpmgo/gopm/doc"
"github.com/gpmgo/gopm/log"
)
var (
workDir string // The path of gopm was executed.
)
// setup initialize common environment for commands.
func setup(ctx *cli.Context) {
var err error
workDir, err = os.Getwd()
if err != nil {
log.Error("setup", "Fail to get work directory:")
log.Fatal("", "\t"+err.Error())
}
log.PureMode = ctx.GlobalBool("noterm")
log.Verbose = ctx.Bool("verbose")
}
// parseTarget returns "." when target is empty string.
func parseTarget(target string) string {
if len(target) == 0 {
target = "."
}
return target
}
// validPath checks if the information of the package is valid.
func validPath(info string) (string, string) {
infos := strings.Split(info, ":")
l := len(infos)
switch {
case l == 1:
// For local imports.
if com.IsFile(infos[0]) {
return doc.LOCAL, infos[0]
}
case l == 2:
switch infos[1] {
case doc.TRUNK, doc.MASTER, doc.DEFAULT:
infos[1] = ""
}
return infos[0], infos[1]
}
log.Error("", "Cannot parse dependency version:")
log.Error("", "\t"+info)
log.Help("Try 'gopm help get' to get more information")
return "", ""
}
func versionSuffix(value string) string {
if len(value) > 0 {
return "." + value
}
return ""
}
func isSubpackage(rootPath, targetPath string) bool {
return strings.HasSuffix(strings.Replace(workDir, "\\", "/", -1), rootPath) ||
strings.HasPrefix(rootPath, targetPath)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tomorrowsj/gopm.git
git@gitee.com:tomorrowsj/gopm.git
tomorrowsj
gopm
gopm
v0.6.5

搜索帮助