forked from Scalingo/cli
/
scale.go
34 lines (32 loc) · 1.05 KB
/
scale.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package cmd
import (
"github.com/Scalingo/cli/Godeps/_workspace/src/github.com/Scalingo/codegangsta-cli"
"github.com/Scalingo/cli/appdetect"
"github.com/Scalingo/cli/apps"
"github.com/Scalingo/cli/cmd/autocomplete"
)
var (
ScaleCommand = cli.Command{
Name: "scale",
Category: "App Management",
Flags: []cli.Flag{appFlag, cli.BoolFlag{Name: "synchronous", Usage: "Do the scaling synchronously", EnvVar: ""}},
Usage: "Scale your application instantly",
Description: `Scale your application processes.
Example
'scalingo --app my-app scale web:2 worker:1'
'scalingo --app my-app scale web:1 worker:0'
'scalingo --app my-app scale web:1:XL'`,
Action: func(c *cli.Context) {
currentApp := appdetect.CurrentApp(c)
if len(c.Args()) == 0 {
cli.ShowCommandHelp(c, "scale")
} else if err := apps.Scale(currentApp, c.Bool("synchronous"), c.Args()); err != nil {
errorQuit(err)
}
},
BashComplete: func(c *cli.Context) {
autocomplete.CmdFlagsAutoComplete(c, "scale")
autocomplete.ScaleAutoComplete(c)
},
}
)