mirror of https://github.com/status-im/fathom.git
add seed_database command
This commit is contained in:
parent
549b4bb055
commit
28a65501af
|
@ -7,18 +7,22 @@ import(
|
||||||
var runCreateUserCommand bool
|
var runCreateUserCommand bool
|
||||||
var runDeleteUserCommand bool
|
var runDeleteUserCommand bool
|
||||||
var runStartServerCommand bool
|
var runStartServerCommand bool
|
||||||
|
var runSeedDatabaseCommand bool
|
||||||
var idArg int
|
var idArg int
|
||||||
var emailArg string
|
var emailArg string
|
||||||
var passwordArg string
|
var passwordArg string
|
||||||
|
var nArg int
|
||||||
|
|
||||||
func Parse() {
|
func Parse() {
|
||||||
// parse commands
|
// parse commands
|
||||||
flag.BoolVar(&runCreateUserCommand, "create_user", false, "Create a new user")
|
flag.BoolVar(&runCreateUserCommand, "create_user", false, "Create a new user")
|
||||||
flag.BoolVar(&runDeleteUserCommand, "delete_user", false, "Deletes a user")
|
flag.BoolVar(&runDeleteUserCommand, "delete_user", false, "Deletes a user")
|
||||||
flag.BoolVar(&runStartServerCommand, "start_server", true, "Start the API web server")
|
flag.BoolVar(&runStartServerCommand, "start_server", true, "Start the API web server")
|
||||||
|
flag.BoolVar(&runSeedDatabaseCommand, "seed_database", false, "Seed the database -n times")
|
||||||
flag.StringVar(&emailArg, "email", "", "Email address")
|
flag.StringVar(&emailArg, "email", "", "Email address")
|
||||||
flag.StringVar(&passwordArg, "password", "", "Password")
|
flag.StringVar(&passwordArg, "password", "", "Password")
|
||||||
flag.IntVar(&idArg, "id", 0, "Object ID")
|
flag.IntVar(&idArg, "id", 0, "Object ID")
|
||||||
|
flag.IntVar(&nArg, "n", 0, "Number")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +31,8 @@ func Run() {
|
||||||
createUser()
|
createUser()
|
||||||
} else if runDeleteUserCommand {
|
} else if runDeleteUserCommand {
|
||||||
deleteUser()
|
deleteUser()
|
||||||
|
} else if runSeedDatabaseCommand {
|
||||||
|
seedDatabase()
|
||||||
} else if runStartServerCommand {
|
} else if runStartServerCommand {
|
||||||
startServer()
|
startServer()
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import(
|
||||||
|
"github.com/dannyvankooten/ana/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
func seedDatabase() {
|
||||||
|
db.Seed(nArg)
|
||||||
|
}
|
Loading…
Reference in New Issue