本文整理匯總了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()
}