/
scale.go
47 lines (43 loc) · 1.13 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
35
36
37
38
39
40
41
42
43
44
45
46
47
package cmd
import (
"github.com/Scalingo/cli/appdetect"
"github.com/Scalingo/cli/apps"
"github.com/Scalingo/cli/cmd/autocomplete"
"github.com/urfave/cli"
)
var (
scaleCommand = cli.Command{
Name: "scale",
ShortName: "s",
Category: "App Management",
Flags: []cli.Flag{appFlag,
cli.BoolFlag{Name: "synchronous, s", 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'
'scalingo --app my-app scale web:+1 worker:-1'
`,
Action: func(c *cli.Context) {
if len(c.Args()) == 0 {
err := cli.ShowCommandHelp(c, "scale")
if err != nil {
errorQuit(err)
}
return
}
currentApp := appdetect.CurrentApp(c)
err := apps.Scale(currentApp, c.Bool("s"), c.Args())
if err != nil {
errorQuit(err)
}
},
BashComplete: func(c *cli.Context) {
autocomplete.CmdFlagsAutoComplete(c, "scale")
autocomplete.ScaleAutoComplete(c)
},
}
)