bug fixed & doc improved
This commit is contained in:
parent
1514830996
commit
d51382a56d
|
@ -30,8 +30,18 @@ to get help
|
||||||
|
|
||||||
example:
|
example:
|
||||||
|
|
||||||
|
sqlite:
|
||||||
`xorm reverse sqite3 test.db templates/goxorm`
|
`xorm reverse sqite3 test.db templates/goxorm`
|
||||||
|
|
||||||
|
mysql:
|
||||||
|
`xorm reverse mysql root:@/xorm_test?charset=utf8 templates/goxorm`
|
||||||
|
|
||||||
|
mymysql:
|
||||||
|
`xorm reverse mymysql xorm_test2/root/ templates/goxorm`
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
`xorm reverse postgres "dbname=xorm_test sslmode=disable" templates/goxorm`
|
||||||
|
|
||||||
will generated go files in `./model` directory
|
will generated go files in `./model` directory
|
||||||
|
|
||||||
## Template and Config
|
## Template and Config
|
||||||
|
|
|
@ -53,6 +53,18 @@ type Tmpl struct {
|
||||||
Model string
|
Model string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dirExists(dir string) bool {
|
||||||
|
d, e := os.Stat(dir)
|
||||||
|
switch {
|
||||||
|
case e != nil:
|
||||||
|
return false
|
||||||
|
case !d.IsDir():
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func runReverse(cmd *Command, args []string) {
|
func runReverse(cmd *Command, args []string) {
|
||||||
num := checkFlags(cmd.Flags, args, printReversePrompt)
|
num := checkFlags(cmd.Flags, args, printReversePrompt)
|
||||||
if num == -1 {
|
if num == -1 {
|
||||||
|
@ -79,6 +91,7 @@ func runReverse(cmd *Command, args []string) {
|
||||||
var genDir string
|
var genDir string
|
||||||
var model string
|
var model string
|
||||||
if len(args) == 4 {
|
if len(args) == 4 {
|
||||||
|
|
||||||
genDir, err = filepath.Abs(args[3])
|
genDir, err = filepath.Abs(args[3])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@ -96,6 +109,11 @@ func runReverse(cmd *Command, args []string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !dirExists(dir) {
|
||||||
|
logging.Error("Template %v path is not exist", dir)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var langTmpl LangTmpl
|
var langTmpl LangTmpl
|
||||||
var ok bool
|
var ok bool
|
||||||
var lang string = "go"
|
var lang string = "go"
|
||||||
|
|
Loading…
Reference in New Issue