本文整理汇总了Golang中github.com/convox/cli/Godeps/_workspace/src/github.com/codegangsta/cli.Context.IsSet方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.IsSet方法的具体用法?Golang Context.IsSet怎么用?Golang Context.IsSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/convox/cli/Godeps/_workspace/src/github.com/codegangsta/cli.Context
的用法示例。
在下文中一共展示了Context.IsSet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: cmdScale
func cmdScale(c *cli.Context) {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
stdcli.Error(err)
return
}
v := url.Values{}
if c.IsSet("count") {
v.Set("count", c.String("count"))
}
if c.IsSet("memory") {
v.Set("mem", c.String("memory"))
}
if len(v) > 0 {
_, err = ConvoxPostForm("/apps/"+app, v)
if err != nil {
stdcli.Error(err)
return
}
}
data, err := ConvoxGet("/apps/" + app)
if err != nil {
stdcli.Error(err)
return
}
var a *App
err = json.Unmarshal(data, &a)
if err != nil {
stdcli.Error(err)
return
}
fmt.Printf("Count %v\n", a.Parameters["DesiredCount"])
fmt.Printf("Memory %v\n", a.Parameters["Memory"])
}
示例2: cmdSystemScale
func cmdSystemScale(c *cli.Context) {
v := url.Values{}
if c.IsSet("count") {
v.Set("count", c.String("count"))
}
if c.IsSet("type") {
v.Set("type", c.String("type"))
}
if len(v) > 0 {
_, err := ConvoxPostForm("/system", v)
if err != nil {
stdcli.Error(err)
return
}
}
cmdSystem(c)
}
示例3: cmdScale
func cmdScale(c *cli.Context) {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
stdcli.Error(err)
return
}
if len(c.Args()) < 1 {
stdcli.Usage(c, "scale")
return
}
v := url.Values{}
if c.IsSet("count") {
v.Set("count", c.String("count"))
}
if c.IsSet("memory") {
v.Set("mem", c.String("memory"))
}
if len(v) > 0 {
v.Set("process", c.Args()[0])
_, err = ConvoxPostForm("/apps/"+app, v)
if err != nil {
stdcli.Error(err)
return
}
}
data, err := ConvoxGet("/apps/" + app)
if err != nil {
stdcli.Error(err)
return
}
var a *App
err = json.Unmarshal(data, &a)
if err != nil {
stdcli.Error(err)
return
}
processes := make(map[string]Process, 0)
longest := 7
for k, v := range a.Parameters {
if !strings.HasSuffix(k, "DesiredCount") {
continue
}
ps := strings.Replace(k, "DesiredCount", "", 1)
p := strings.ToLower(ps)
i, err := strconv.ParseInt(v, 10, 64)
if err != nil {
stdcli.Error(err)
return
}
m, err := strconv.ParseInt(a.Parameters[ps+"Memory"], 10, 64)
if err != nil {
stdcli.Error(err)
return
}
processes[p] = Process{Name: p, Count: i, Memory: m}
}
fmt.Printf(fmt.Sprintf("%%-%ds %%-5s %%-5s\n", longest), "PROCESS", "COUNT", "MEM")
for _, ps := range processes {
fmt.Printf(fmt.Sprintf("%%-%ds %%-5d %%-5d\n", longest), ps.Name, ps.Count, ps.Memory)
}
}
示例4: cmdScale
func cmdScale(c *cli.Context) {
_, app, err := stdcli.DirApp(c, ".")
if err != nil {
stdcli.Error(err)
return
}
v := url.Values{}
if c.IsSet("count") {
v.Set("count", c.String("count"))
}
if c.IsSet("memory") {
v.Set("mem", c.String("memory"))
}
if len(v) > 0 {
v.Set("process", c.Args()[0])
_, err = ConvoxPostForm("/apps/"+app, v)
if err != nil {
stdcli.Error(err)
return
}
}
data, err := ConvoxGet("/apps/" + app)
if err != nil {
stdcli.Error(err)
return
}
var a *App
err = json.Unmarshal(data, &a)
if err != nil {
stdcli.Error(err)
return
}
processes := map[string]Process{}
names := []string{}
for k, v := range a.Parameters {
if !strings.HasSuffix(k, "DesiredCount") {
continue
}
ps := strings.Replace(k, "DesiredCount", "", 1)
p := strings.ToLower(ps)
i, err := strconv.ParseInt(v, 10, 64)
if err != nil {
stdcli.Error(err)
return
}
m, err := strconv.ParseInt(a.Parameters[ps+"Memory"], 10, 64)
if err != nil {
stdcli.Error(err)
return
}
processes[p] = Process{Name: p, Count: i, Memory: m}
names = append(names, p)
}
sort.Strings(names)
t := stdcli.NewTable("PROCESS", "COUNT", "MEM")
for _, name := range names {
ps := processes[name]
t.AddRow(ps.Name, fmt.Sprintf("%d", ps.Count), fmt.Sprintf("%d", ps.Memory))
}
t.Print()
}