/
config.go
40 lines (36 loc) · 911 Bytes
/
config.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
package cmd
import (
"github.com/Scalingo/cli/cmd/autocomplete"
"github.com/Scalingo/cli/config"
"github.com/urfave/cli"
)
var (
ConfigCommand = cli.Command{
Name: "config",
Category: "Global",
Usage: "Configure the CLI",
Flags: []cli.Flag{
cli.StringFlag{Name: "region", Value: "", Usage: "Configure the default region used by the CLI"},
},
Description: `
Example
'scalingo config --region agora-fr1'
Can also be configured using the environment variable
SCALINGO_REGION=agora-fr1`,
Action: func(c *cli.Context) {
if c.String("region") != "" {
err := config.SetRegion(c.String("region"))
if err != nil {
errorQuit(err)
}
}
// If no flag are given, display the current config
if c.String("region") == "" {
config.Display()
}
},
BashComplete: func(c *cli.Context) {
autocomplete.CmdFlagsAutoComplete(c, "config")
},
}
)