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


Golang Context.Bool方法代碼示例

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


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

示例1: runServerReboot

func runServerReboot(c *cli.Context) {
	stack := mustStack(c)

	if len(c.Args()) != 0 {
		cli.ShowSubcommandHelp(c)
		os.Exit(2)
	}

	serverName := c.String("server")
	servers, err := client.Servers(stack.Uid)
	if err != nil {
		printFatal(err.Error())
	}

	server, err := findServer(servers, serverName)
	if err != nil {
		printFatal(err.Error())
	}

	if server == nil {
		printFatal("Server '" + serverName + "' not found")
	}

	fmt.Printf("Server: %s\n", server.Name)

	// confirmation is needed if the stack is production
	if !c.Bool("y") {
		mustConfirm("This operation will reboot your server during which time your server will not be available. Proceed with reboot? [yes/N]", "yes")
	}
	executeServerReboot(*stack, *server)
}
開發者ID:magiccreater,項目名稱:cx,代碼行數:31,代碼來源:servers-reboot.go

示例2: runEnvVars

func runEnvVars(c *cli.Context) {
	w := tabwriter.NewWriter(os.Stdout, 1, 2, 2, ' ', 0)
	defer w.Flush()
	var envVars []cloud66.StackEnvVar
	var err error
	stack := mustStack(c)
	envVars, err = client.StackEnvVars(stack.Uid)
	must(err)

	envVarKeys := c.Args()
	flagShowHistory := c.Bool("history")

	sort.Strings(envVarKeys)
	if len(envVarKeys) == 0 {
		printEnvVarsList(w, envVars, flagShowHistory)
	} else {
		// filter out the unwanted env_vars
		var filteredEnvVars []cloud66.StackEnvVar
		for _, i := range envVars {
			sorted := sort.SearchStrings(envVarKeys, i.Key)
			if sorted < len(envVarKeys) && envVarKeys[sorted] == i.Key {
				filteredEnvVars = append(filteredEnvVars, i)
			}
		}
		printEnvVarsList(w, filteredEnvVars, flagShowHistory)
	}
}
開發者ID:sgtpepper43,項目名稱:cx,代碼行數:27,代碼來源:env-vars.go

示例3: runContainers

func runContainers(c *cli.Context) {
	stack := mustStack(c)
	w := tabwriter.NewWriter(os.Stdout, 1, 2, 2, ' ', 0)
	defer w.Flush()

	flagServer := c.String("server")
	flagServiceName := c.String("service")
	flagTruncate := c.Bool("trunc")

	var serverUid *string
	if flagServer == "" {
		serverUid = nil
	} else {
		servers, err := client.Servers(stack.Uid)
		if err != nil {
			printFatal(err.Error())
		}
		server, err := findServer(servers, flagServer)
		if err != nil {
			printFatal(err.Error())
		}
		if server == nil {
			printFatal("Server '" + flagServer + "' not found")
		}
		fmt.Printf("Server: %s\n", server.Name)
		serverUid = &server.Uid
	}

	containers, err := client.GetContainers(stack.Uid, serverUid, &flagServiceName)
	must(err)

	printContainerList(w, containers, flagTruncate)
}
開發者ID:sgtpepper43,項目名稱:cx,代碼行數:33,代碼來源:containers.go

示例4: runBackups

func runBackups(c *cli.Context) {
	var dbType = c.String("dbtype")

	w := tabwriter.NewWriter(os.Stdout, 1, 2, 2, ' ', 0)
	defer w.Flush()

	stack := mustStack(c)

	backups, err := client.ManagedBackups(stack.Uid)
	must(err)

	var dbTypeGroup = map[string][]cloud66.ManagedBackup{}
	if c.Bool("latest") {
		for _, i := range backups {
			if dbTypeGroup[i.DbType] == nil {
				// it's a new one
				dbTypeGroup[i.DbType] = []cloud66.ManagedBackup{i}
			} else {
				dbTypeGroup[i.DbType] = append(dbTypeGroup[i.DbType], i)
			}
		}

		// now sort each group
		topResults := []cloud66.ManagedBackup{}
		for _, v := range dbTypeGroup {
			sort.Sort(backupsByDate(v))
			topResults = append(topResults, v[0])
		}
		printBackupList(w, topResults, dbType)
	} else {
		printBackupList(w, backups, dbType)
	}
}
開發者ID:sgtpepper43,項目名稱:cx,代碼行數:33,代碼來源:backups.go

示例5: runNewBackup

func runNewBackup(c *cli.Context) {
	stack := mustStack(c)

	var flagDbTypes *string

	if c.IsSet("dbtypes") {
		flagDbTypes = new(string)
		*flagDbTypes = c.String("dbtypes")
	}

	var flagFrequency *string

	if c.IsSet("frequency") {
		flagFrequency = new(string)
		*flagFrequency = c.String("frequency")
	}

	var flagKeep *int

	if c.IsSet("keep") {
		flagKeep = new(int)
		*flagKeep = c.Int("keep")
	}

	var flagGzip *bool

	if c.IsSet("gzip") {
		flagGzip = new(bool)
		*flagGzip = c.Bool("gzip")
	}

	var flagExcludetables *string

	if c.IsSet("exclude-tables") {
		flagExcludetables = new(string)
		*flagExcludetables = c.String("exclude-tables")
	}

	var flagRunonreplica *bool

	if c.IsSet("run-on-replica") {
		flagRunonreplica = new(bool)
		*flagRunonreplica = c.Bool("run-on-replica")
	}

	err := client.NewBackup(stack.Uid, flagDbTypes, flagFrequency, flagKeep, flagGzip, flagExcludetables, flagRunonreplica)

	if err != nil {
		printFatal("Error during backup creation: " + err.Error())
		return
	}

	fmt.Println("queued for creation")
}
開發者ID:sgtpepper43,項目名稱:cx,代碼行數:54,代碼來源:backups-new.go

示例6: runRedeploy

func runRedeploy(c *cli.Context) {
	stack := mustStack(c)

	// confirmation is needed if the stack is production
	if stack.Environment == "production" && !c.Bool("y") {
		mustConfirm("This is a production stack. Proceed with deployment? [yes/N]", "yes")
	}

	if len(c.StringSlice("service")) > 0 {
		fmt.Printf("Deploying service(s): ")
		for i, service := range c.StringSlice("service") {
			if i > 0 {
				fmt.Printf(", ")
			}
			fmt.Printf(service)
		}
		fmt.Printf("\n")
	}

	result, err := client.RedeployStack(stack.Uid, c.String("git-ref"), c.StringSlice("service"))
	must(err)

	if !c.Bool("listen") || result.Queued {
		// its queued - just message and exit
		fmt.Println(result.Message)
	} else {
		// tail the logs
		go StartListen(stack)

		stack, err = WaitStackBuild(stack.Uid, false)
		must(err)

		if stack.HealthCode == 2 || stack.HealthCode == 4 || stack.StatusCode == 2 || stack.StatusCode == 7 {
			fmt.Println("Completed with some errors!")
		} else {
			fmt.Println("Completed successfully!")
		}
	}
}
開發者ID:sgtpepper43,項目名稱:cx,代碼行數:39,代碼來源:stacks-redeploy.go


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