forked from Scalingo/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpgsql.go
More file actions
59 lines (51 loc) · 1.79 KB
/
pgsql.go
File metadata and controls
59 lines (51 loc) · 1.79 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
package cmd
import (
"github.com/urfave/cli/v2"
"github.com/Scalingo/cli/cmd/autocomplete"
"github.com/Scalingo/cli/db"
"github.com/Scalingo/cli/detect"
"github.com/Scalingo/cli/utils"
)
var (
PgSQLConsoleCommand = cli.Command{
Name: "pgsql-console",
Aliases: []string{"psql-console", "postgresql-console"},
Category: "Databases",
Usage: "Run an interactive console with your PostgreSQL addon",
Flags: []cli.Flag{&appFlag,
&cli.StringFlag{Name: "size", Aliases: []string{"s"}, Value: "", Usage: "Size of the container"},
&cli.StringFlag{Name: "env", Aliases: []string{"e"}, Value: "", Usage: "Environment variable name to use for the connection to the database"},
},
Description: ` Run an interactive console with your PostgreSQL addon.
Examples
scalingo --app my-app pgsql-console
scalingo --app my-app pgsql-console --size L
scalingo --app my-app pgsql-console --env MY_PSQL_URL
The --size flag makes it easy to specify the size of the container executing
the PostgreSQL console. Each container size has different price and performance.
You can read more about container sizes here:
http://doc.scalingo.com/internals/container-sizes.html
# See also 'mongo-console' and 'mysql-console'
`,
Action: func(c *cli.Context) error {
if c.Args().Len() != 0 {
cli.ShowCommandHelp(c, "pgsql-console")
return nil
}
currentApp := detect.CurrentApp(c)
utils.CheckForConsent(c.Context, currentApp, utils.ConsentTypeDBs)
err := db.PgSQLConsole(c.Context, db.PgSQLConsoleOpts{
App: currentApp,
Size: c.String("s"),
VariableName: c.String("e"),
})
if err != nil {
errorQuit(err)
}
return nil
},
BashComplete: func(c *cli.Context) {
autocomplete.CmdFlagsAutoComplete(c, "pgsql-console")
},
}
)