From e455509adbce1b6c089e56c244d3c05a9f64b2d8 Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Wed, 13 Aug 2014 14:48:20 +0800 Subject: [PATCH] load params from json and minor output format fix --- g.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/g.go b/g.go index 61bae82..2ca735d 100644 --- a/g.go +++ b/g.go @@ -102,19 +102,30 @@ func generateCode(cmd *Command, args []string) { case "docs": generateDocs(curpath) case "appcode": + // load config + err := loadConfig() + if err != nil { + ColorLog("[ERRO] Fail to parse bee.json[ %s ]\n", err) + } cmd.Flag.Parse(args[1:]) if driver == "" { - driver = "mysql" + driver = docValue(conf.Database.Driver) + if driver == "" { + driver = "mysql" + } } if conn == "" { - conn = "root:@tcp(127.0.0.1:3306)/test" + conn = docValue(conf.Database.Conn) + if conn == "" { + conn = "root:@tcp(127.0.0.1:3306)/test" + } } if level == "" { level = "3" } ColorLog("[INFO] Using '%s' as 'driver'\n", driver) ColorLog("[INFO] Using '%s' as 'conn'\n", conn) - ColorLog("[INFO] Using '%s' as 'tables'", tables) + ColorLog("[INFO] Using '%s' as 'tables'\n", tables) ColorLog("[INFO] Using '%s' as 'level'\n", level) generateAppcode(string(driver), string(conn), string(level), string(tables), curpath) case "migration":