-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (38 loc) · 899 Bytes
/
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
43
package main
import (
"log"
"os"
"github.com/ayaanqui/go-migration-tool/migration_tool"
"github.com/urfave/cli"
)
func main() {
config := migration_tool.Config{}
app := &cli.App{
Flags: []cli.Flag{
&cli.StringFlag{
Name: "directory",
Usage: "specifies the directory that results are stored",
Destination: &config.Directory,
Required: true,
},
},
Commands: []cli.Command{
{
Name: "create-migration",
ShortName: "c",
Usage: "creates a new migration file",
Action: func(c *cli.Context) error {
m := migration_tool.MigrationTool{
Config: &config,
}
m.Config.Directory = migration_tool.StripTrailingSlash(m.Config.Directory)
migration_name := c.Args().First()
return m.CreateMigrationFile(migration_name)
},
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}