adding log information to show prograss

This commit is contained in:
ZhengYang 2014-08-01 18:07:38 +08:00
parent 348bc3edcb
commit 30564d388a
1 changed files with 7 additions and 0 deletions

View File

@ -202,6 +202,7 @@ func gen(dbms string, connStr string, mode byte, currpath string) {
os.Exit(2) os.Exit(2)
} }
defer db.Close() defer db.Close()
ColorLog("[INFO] Analyzing database tables...\n")
tableNames := getTableNames(db) tableNames := getTableNames(db)
tables := getTableObjects(tableNames, db) tables := getTableObjects(tableNames, db)
mvcPath := new(MvcPath) mvcPath := new(MvcPath)
@ -408,12 +409,15 @@ func deleteAndRecreatePaths(mode byte, paths *MvcPath) {
// Newly geneated files will be inside these folders. // Newly geneated files will be inside these folders.
func writeSourceFiles(tables []*Table, mode byte, paths *MvcPath) { func writeSourceFiles(tables []*Table, mode byte, paths *MvcPath) {
if (O_MODEL & mode) == O_MODEL { if (O_MODEL & mode) == O_MODEL {
ColorLog("[INFO] Creating model files...\n")
writeModelFiles(tables, paths.ModelPath) writeModelFiles(tables, paths.ModelPath)
} }
if (O_CONTROLLER & mode) == O_CONTROLLER { if (O_CONTROLLER & mode) == O_CONTROLLER {
ColorLog("[INFO] Creating controller files...\n")
writeControllerFiles(tables, paths.ControllerPath) writeControllerFiles(tables, paths.ControllerPath)
} }
if (O_ROUTER & mode) == O_ROUTER { if (O_ROUTER & mode) == O_ROUTER {
ColorLog("[INFO] Creating router files...\n")
writeRouterFile(tables, paths.RouterPath) writeRouterFile(tables, paths.RouterPath)
} }
} }
@ -437,6 +441,7 @@ func writeModelFiles(tables []*Table, mPath string) {
ColorLog("[ERRO] Could not write model file to %s\n", fpath) ColorLog("[ERRO] Could not write model file to %s\n", fpath)
os.Exit(2) os.Exit(2)
} }
ColorLog("[INFO] model => %s\n", fpath)
formatAndFixImports(fpath) formatAndFixImports(fpath)
} }
} }
@ -456,6 +461,7 @@ func writeControllerFiles(tables []*Table, cPath string) {
ColorLog("[ERRO] Could not write controller file to %s\n", fpath) ColorLog("[ERRO] Could not write controller file to %s\n", fpath)
os.Exit(2) os.Exit(2)
} }
ColorLog("[INFO] controller => %s\n", fpath)
formatAndFixImports(fpath) formatAndFixImports(fpath)
} }
} }
@ -481,6 +487,7 @@ func writeRouterFile(tables []*Table, rPath string) {
ColorLog("[ERRO] Could not write router file to %s\n", fpath) ColorLog("[ERRO] Could not write router file to %s\n", fpath)
os.Exit(2) os.Exit(2)
} }
ColorLog("[INFO] router => %s\n", fpath)
formatAndFixImports(fpath) formatAndFixImports(fpath)
} }