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


Golang Context.StringSlice方法代碼示例

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


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

示例1: runJobRun

func runJobRun(c *cli.Context) {

	stack := mustStack(c)

	// get the job
	if len(c.Args()) != 1 {
		cli.ShowSubcommandHelp(c)
		os.Exit(2)
	}
	jobName := c.Args()[0]

	jobs, err := client.GetJobs(stack.Uid, nil)
	if err != nil {
		printFatal(err.Error())
	}

	var jobNames []string
	for _, job := range jobs {
		jobNames = append(jobNames, job.GetBasicJob().Name)
	}

	idx, err := fuzzyFind(jobNames, jobName, false)
	if err != nil {
		printFatal(err.Error())
	}
	jobUid := string(jobs[idx].GetBasicJob().Uid)

	jobArgs := ""

	if len(c.StringSlice("arg")) > 0 {
		for i, arg := range c.StringSlice("arg") {
			if i > 0 {
				jobArgs = jobArgs + " "
			}
			jobArgs = jobArgs + "\"" + arg + "\""
		}
	}

	asyncId, err := startJobRun(stack.Uid, jobUid, &jobArgs)
	if err != nil {
		printFatal(err.Error())
	}
	genericRes, err := endJobRun(*asyncId, stack.Uid)
	if err != nil {
		printFatal(err.Error())
	}
	printGenericResponse(*genericRes)
	return
}
開發者ID:magiccreater,項目名稱:cx,代碼行數:49,代碼來源:jobs-run.go

示例2: 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.StringSlice方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。