當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Context.GlobalBool方法代碼示例

本文整理匯總了Golang中github.com/cloud66/cli.Context.GlobalBool方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.GlobalBool方法的具體用法?Golang Context.GlobalBool怎麽用?Golang Context.GlobalBool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cloud66/cli.Context的用法示例。


在下文中一共展示了Context.GlobalBool方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: beforeCommand

func beforeCommand(c *cli.Context) error {
	// set the env vars from global options
	if c.GlobalString("runenv") != "production" {
		tokenFile = "cx_" + c.GlobalString("runenv") + ".json"
		fmt.Printf(ansi.Color(fmt.Sprintf("Running against %s environment\n", c.GlobalString("runenv")), "grey"))
		honeybadger.Environment = c.GlobalString("runenv")
	} else {
		honeybadger.Environment = "production"
	}

	if c.GlobalString("fayeEndpoint") != "" {
		fayeEndpoint = c.GlobalString("fayeEndpoint")
	}

	debugMode = c.GlobalBool("debug")

	var command string
	if len(c.Args()) >= 1 {
		command = c.Args().First()
	}

	if (command != "version") && (command != "help") && (command != "update") {
		initClients(c)
	}

	if (command != "update") && (VERSION != "dev") {
		defer backgroundRun()
	}

	return nil
}
開發者ID:sgtpepper43,項目名稱:cx,代碼行數:31,代碼來源:main.go

示例2: initClients

func initClients(c *cli.Context) {
	// is there a token file?
	_, err := os.Stat(filepath.Join(cxHome(), tokenFile))
	if err != nil {
		fmt.Println("No previous authentication found.")
		cloud66.Authorize(cxHome(), tokenFile)
		os.Exit(1)
	} else {
		client = cloud66.GetClient(cxHome(), tokenFile, VERSION)
		debugMode = c.GlobalBool("debug")
		client.Debug = debugMode
	}
}
開發者ID:sgtpepper43,項目名稱:cx,代碼行數:13,代碼來源:main.go

示例3: runUpdate

func runUpdate(c *cli.Context) {
	debugMode = c.GlobalBool("debug")
	flagForcedVersion = c.String("force")

	if debugMode {
		fmt.Printf("Current version is %s\n", VERSION)
		if flagForcedVersion == "" {
			fmt.Println("No forced version")
		} else {
			fmt.Printf("Forced version is %s\n", flagForcedVersion)
		}
	}
	updateIt, err := needUpdate()
	if err != nil {
		if debugMode {
			fmt.Printf("Cannot verify need for update %v\n", err)
		}
		return
	}
	if !updateIt {
		if debugMode {
			fmt.Println("No need for update")
		}
		return
	}

	// houston we have an update. which one do we need?
	download, err := getVersionManifest(flagForcedVersion)
	if err != nil {
		if debugMode {
			fmt.Printf("Error fetching manifest %v\n", err)
		}
	}
	if download == nil {
		if debugMode {
			fmt.Println("Found no matching download for the current OS and ARCH")
		}
		return
	}

	err = download.update()
	if err != nil {
		if debugMode {
			fmt.Printf("Failed to update: %v\n", err)
		}
		return
	}
}
開發者ID:sgtpepper43,項目名稱:cx,代碼行數:48,代碼來源:update.go


注:本文中的github.com/cloud66/cli.Context.GlobalBool方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。