bug fixed & doc improved

This commit is contained in:
Lunny Xiao 2013-10-20 10:43:49 +08:00
parent 1514830996
commit d51382a56d
2 changed files with 28 additions and 0 deletions

View File

@ -30,8 +30,18 @@ to get help
example:
sqlite:
`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
## Template and Config

View File

@ -53,6 +53,18 @@ type Tmpl struct {
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) {
num := checkFlags(cmd.Flags, args, printReversePrompt)
if num == -1 {
@ -79,6 +91,7 @@ func runReverse(cmd *Command, args []string) {
var genDir string
var model string
if len(args) == 4 {
genDir, err = filepath.Abs(args[3])
if err != nil {
fmt.Println(err)
@ -96,6 +109,11 @@ func runReverse(cmd *Command, args []string) {
return
}
if !dirExists(dir) {
logging.Error("Template %v path is not exist", dir)
return
}
var langTmpl LangTmpl
var ok bool
var lang string = "go"