本文整理汇总了Golang中github.com/swan-go/gopm/modules/cli.Context.GlobalBool方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.GlobalBool方法的具体用法?Golang Context.GlobalBool怎么用?Golang Context.GlobalBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/swan-go/gopm/modules/cli.Context
的用法示例。
在下文中一共展示了Context.GlobalBool方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: setup
// setup initializes and checks common environment variables.
func setup(ctx *cli.Context) (err error) {
setting.Debug = ctx.GlobalBool("debug")
log.NonColor = ctx.GlobalBool("noterm")
log.Verbose = ctx.Bool("verbose")
log.Info("App Version: %s", ctx.App.Version)
setting.HomeDir, err = base.HomeDir()
if err != nil {
return fmt.Errorf("Fail to get home directory: %v", err)
}
setting.HomeDir = strings.Replace(setting.HomeDir, "\\", "/", -1)
setting.InstallRepoPath = path.Join(setting.HomeDir, ".gopm/repos")
if runtime.GOOS == "windows" {
setting.IsWindows = true
}
os.MkdirAll(setting.InstallRepoPath, os.ModePerm)
log.Info("Local repository path: %s", setting.InstallRepoPath)
if !setting.LibraryMode || len(setting.WorkDir) == 0 {
setting.WorkDir, err = os.Getwd()
if err != nil {
return fmt.Errorf("Fail to get work directory: %v", err)
}
setting.WorkDir = strings.Replace(setting.WorkDir, "\\", "/", -1)
}
setting.DefaultGopmfile = path.Join(setting.WorkDir, setting.GOPMFILE)
setting.DefaultVendor = path.Join(setting.WorkDir, setting.VENDOR)
setting.DefaultVendorSrc = path.Join(setting.DefaultVendor, "src")
if !ctx.Bool("remote") {
if ctx.Bool("local") {
// gf, _, _, err := genGopmfile(ctx)
// if err != nil {
// return err
// }
// setting.InstallGopath = gf.MustValue("project", "local_gopath")
// if ctx.Command.Name != "gen" {
// if com.IsDir(setting.InstallGopath) {
// log.Log("Indicated local GOPATH: %s", setting.InstallGopath)
// setting.InstallGopath += "/src"
// } else {
// if setting.LibraryMode {
// return fmt.Errorf("Local GOPATH does not exist or is not a directory: %s",
// setting.InstallGopath)
// }
// log.Error("", "Invalid local GOPATH path")
// log.Error("", "Local GOPATH does not exist or is not a directory:")
// log.Error("", "\t"+setting.InstallGopath)
// log.Help("Try 'go help gopath' to get more information")
// }
// }
} else {
// Get GOPATH.
setting.InstallGopath = base.GetGOPATHs()[0]
if base.IsDir(setting.InstallGopath) {
log.Info("Indicated GOPATH: %s", setting.InstallGopath)
setting.InstallGopath += "/src"
setting.HasGOPATHSetting = true
} else {
if ctx.Bool("gopath") {
return fmt.Errorf("Local GOPATH does not exist or is not a directory: %s",
setting.InstallGopath)
} else {
// It's OK that no GOPATH setting
// when user does not specify to use.
log.Warn("No GOPATH setting available")
}
}
}
}
setting.ConfigFile = path.Join(setting.HomeDir, ".gopm/data/gopm.ini")
if err = setting.LoadConfig(); err != nil {
return err
}
setting.PkgNameListFile = path.Join(setting.HomeDir, ".gopm/data/pkgname.list")
if err = setting.LoadPkgNameList(); err != nil {
return err
}
setting.LocalNodesFile = path.Join(setting.HomeDir, ".gopm/data/localnodes.list")
if err = setting.LoadLocalNodes(); err != nil {
return err
}
setting.LocalizeConfigFile = path.Join(setting.HomeDir, ".gopm/data/localize.ini")
if err = setting.LoadLocalize(); err != nil {
return err
}
return nil
}