-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (40 loc) · 1.08 KB
/
main.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
package main
import (
"github.com/urfave/cli/v2"
"log"
"os"
"pgsafemigrate/cmd"
"pgsafemigrate/reporter"
)
func main() {
app := &cli.App{
Name: "pgsafemigrate",
Version: "v0.1.0",
Description: "Analyzes and detects common errors in migration SQL statements",
Commands: []*cli.Command{
{
Name: "check",
Usage: "Check SQL statements in migration files",
Description: "The check sub-command will process each migration file separately and produce a report. " +
"Exits with a non-zero exit code on failure. Migration file paths are given as positional arguments.",
Flags: []cli.Flag{
cmd.ExcludedRulesFlag(),
},
Action: func(ctx *cli.Context) error {
// TODO: make reporter configurable
return cmd.Check(ctx, ctx.Args().Slice(), ctx.StringSlice(cmd.ExcludedRulesFlag().Name), reporter.PlainText{})
},
},
{
Name: "list-rules",
Usage: "List available rules",
Action: func(ctx *cli.Context) error {
return cmd.ListRules(ctx)
},
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}