本文整理匯總了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
}
示例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!")
}
}
}