@@ -11,6 +11,7 @@ package main
1111import (
1212 "encoding/json"
1313 "flag"
14+ "fmt"
1415 "github.com/xfali/gobatis-cmd/internal/pkg/db"
1516 "github.com/xfali/gobatis-cmd/internal/pkg/generator"
1617 "github.com/xfali/gobatis-cmd/pkg/config"
@@ -50,27 +51,28 @@ func main() {
5051 if * confFile != "" {
5152 err := loadFromFile (& conf , * confFile )
5253 if err != nil {
54+ fmt .Println (err )
5355 os .Exit (1 )
5456 }
57+ conf .Path = formatPath (conf .Path )
58+ } else {
59+ conf .Driver = * driver
60+ conf .Path = formatPath (* path )
61+ conf .PackageName = * packageName
62+ conf .Namespace = * namespace
63+ conf .ModelFile = * modelfile
64+ conf .TagName = * tagName
65+ conf .MapperFile = * mapper
66+ conf .Plugin = * plugin
67+ conf .Keyword = * keyword
68+ conf .TableName = * tableName
69+ conf .DBName = * dbName
70+ conf .Host = * host
71+ conf .Port = * port
72+ conf .User = * username
73+ conf .Password = * pw
5574 }
5675
57- root := formatPath (* path )
58- conf .Driver = * driver
59- conf .Path = root
60- conf .PackageName = * packageName
61- conf .Namespace = * namespace
62- conf .ModelFile = * modelfile
63- conf .TagName = * tagName
64- conf .MapperFile = * mapper
65- conf .Plugin = * plugin
66- conf .Keyword = * keyword
67- conf .TableName = * tableName
68- conf .DBName = * dbName
69- conf .Host = * host
70- conf .Port = * port
71- conf .User = * username
72- conf .Password = * pw
73-
7476 err := dbDriver .Open (conf .Driver , db .GenDBInfo (conf .Driver , conf .DBName , conf .User , conf .Password , conf .Host , conf .Port ))
7577 if err != nil {
7678 log .Print (err )
@@ -98,6 +100,7 @@ func loadFromFile(conf *config.FileConfig, path string) error {
98100 if err != nil {
99101 return err
100102 }
103+ fmt .Printf ("config file: %s\n " , string (b ))
101104 return json .Unmarshal (b , conf )
102105}
103106
0 commit comments