本文整理汇总了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!")
}
}
}