本文整理汇总了Golang中github.com/codegangsta/cli.Context.IntSlice方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.IntSlice方法的具体用法?Golang Context.IntSlice怎么用?Golang Context.IntSlice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/codegangsta/cli.Context
的用法示例。
在下文中一共展示了Context.IntSlice方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: doCmd
func doCmd(c *cli.Context, cmd *exec.Cmd, forceRegexpSlice, suppressRegexpSlice regexpSlice) {
var (
out bytes.Buffer
err error
)
cmd.Stderr = &out
if !c.Bool(`omit-stdout`) {
cmd.Stdout = &out
}
if err = cmd.Start(); err != nil {
fmt.Fprintf(os.Stderr, "Could not start process: %v", err)
os.Exit(1)
}
err = cmd.Wait()
if regexpSliceMatches(out.Bytes(), forceRegexpSlice) {
exit(out.String(), 1)
} else if exitError, ok := err.(*exec.ExitError); ok {
// Exited non-zero
if status, ok := exitError.Sys().(syscall.WaitStatus); ok {
exitCode := status.ExitStatus()
if !intInSlice(exitCode, c.IntSlice(`suppress-exit-code`)) && !regexpSliceMatches(out.Bytes(), suppressRegexpSlice) {
exit(out.String(), exitCode)
}
} else {
exit(fmt.Sprintf("Unhandled error, sending output: %s\n%v", err, out), 1)
}
}
}
示例2: getIntSliceOption
func getIntSliceOption(ctx *cli.Context, flag string, required bool) []int {
slice := ctx.IntSlice(flag)
if required && (!ctx.IsSet(flag) || len(slice) == 0) {
exitOnError(fmt.Errorf("--%s must specify at least one integer value", flag))
}
return slice
}
示例3: create
func create(c *cli.Context) {
checkArgs(c)
d := dogo.Droplet{
Name: c.Args().First(),
ImageID: c.Int("image"),
SizeID: dogo.SizesMap[c.String("size")],
RegionID: dogo.RegionsMap[c.String("region")],
BackupsActive: c.BoolT("backups"),
}
keys := c.IntSlice("keys")
network := c.BoolT("network")
_, err := docli.CreateDroplet(d, keys, network)
if err != nil {
fatalf(err.Error())
}
fmt.Printf("Successfully queued %s for creation ... \n", d.Name)
}
示例4: cliRender
func cliRender(c *cli.Context) {
var config flame.Config
config.Dims.Width = 400
config.Dims.Height = 400
config.Iterations = 10 * 1000 * 1000
config.Functions = []flame.FunConfig{
{5},
{7},
}
config.DataOut = c.String("dataout")
config.DataIn = c.String("datain")
config.NoImage = c.Bool("noimage")
if c.String("config") != "" {
flame.ReadConfig(c.String("config"), &config)
}
if c.Int("width") != 0 {
config.Dims.Width = c.Int("width")
}
if c.Int("height") != 0 {
config.Dims.Height = c.Int("height")
}
config.Dims.X, _ = strconv.ParseFloat(c.String("x"), 64)
config.Dims.Y, _ = strconv.ParseFloat(c.String("y"), 64)
config.Dims.Xscale, _ = strconv.ParseFloat(c.String("xscale"), 64)
config.Dims.Yscale, _ = strconv.ParseFloat(c.String("yscale"), 64)
if c.Int("iterations") != 0 {
config.Iterations = c.Int("iterations")
}
if len(c.IntSlice("f")) != 0 {
config.Functions = make([]flame.FunConfig, len(c.IntSlice("f")))
for i, v := range c.IntSlice("f") {
config.Functions[i] = flame.FunConfig{v}
}
}
outfile := "-"
if c.String("outfile") != "" {
outfile = c.String("outfile")
}
image, _ := flame.Flame(config)
if image != nil {
write(outfile, image)
}
}