-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcommand.go
More file actions
44 lines (35 loc) · 698 Bytes
/
Copy pathcommand.go
File metadata and controls
44 lines (35 loc) · 698 Bytes
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
package main
import (
"errors"
"strings"
"github.com/miaogaolin/sql2ent/util"
"github.com/miaogaolin/sql2ent/gen"
"github.com/urfave/cli"
)
const (
flagSrc = "src"
flagDir = "dir"
)
func MysqlDDL(cli *cli.Context) error {
src := cli.String(flagSrc)
dir := cli.String(flagDir)
src = strings.TrimSpace(src)
if len(src) == 0 {
return errors.New("expected path or path globbing patterns, but nothing found")
}
files, err := util.MatchFiles(src)
if err != nil {
return err
}
if len(files) == 0 {
return errors.New("sql not matched")
}
g := gen.NewMysqlGenerator(dir)
for _, f := range files {
err := g.FromFile(f)
if err != nil {
return err
}
}
return nil
}