-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (35 loc) · 807 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
package main
import (
"errors"
"log"
"os"
"github.com/sky0621/kreu-crud-for-sqlc/internal"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
Name: "kreu-crud-for-sqlc",
Usage: "create a CRUD diagram based on the file for sqlc.",
Action: func(c *cli.Context) error {
args := c.Args().Slice()
if len(args) == 0 {
return errors.New("need 'root path' arg")
}
log.Printf("root path: %s\n", args[0])
return execMain(args[0], args[1:])
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}
func execMain(rootPath string, targetSQLName []string) error {
result, err := internal.CollectSQLParseResult(rootPath, targetSQLName)
if err != nil {
return err
}
if err := internal.Output(rootPath, result); err != nil {
return err
}
return nil
}