diff --git a/db.go b/db.go index 06780b6..0754802 100644 --- a/db.go +++ b/db.go @@ -22,7 +22,6 @@ type User struct { } func dbInit(db *gorm.DB) error { - db.LogMode(true) db.AutoMigrate(&User{}) db.AutoMigrate(&Key{}) db.AutoMigrate(&Host{}) diff --git a/main.go b/main.go index 6c4e81c..5cab445 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( "github.com/gliderlabs/ssh" "github.com/jinzhu/gorm" + _ "github.com/jinzhu/gorm/dialects/mysql" _ "github.com/jinzhu/gorm/dialects/sqlite" "github.com/urfave/cli" ) @@ -42,13 +43,17 @@ func main() { cli.StringFlag{ Name: "db-driver", Value: "sqlite3", + Usage: "GORM driver (sqlite3, mysql)", }, cli.StringFlag{ Name: "db-conn", Value: "./sshportal.db", + Usage: "GORM connection string", + }, + cli.BoolFlag{ + Name: "debug, D", + Usage: "Display debug information", }, - // TODO: add verbose mode - // TODO: add web server } app.Action = server app.Run(os.Args) @@ -60,6 +65,9 @@ func server(c *cli.Context) error { return err } defer db.Close() + if c.Bool("debug") { + db.LogMode(true) + } if err := dbInit(db); err != nil { return err }