2016-12-08 19:45:26 +00:00
|
|
|
package commands
|
|
|
|
|
2016-12-11 13:50:01 +00:00
|
|
|
import (
|
|
|
|
"flag"
|
2016-12-08 19:45:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var runCreateUserCommand bool
|
2016-12-08 19:57:44 +00:00
|
|
|
var runDeleteUserCommand bool
|
2016-12-08 19:45:26 +00:00
|
|
|
var runStartServerCommand bool
|
2016-12-11 09:58:58 +00:00
|
|
|
var runSeedDataCommand bool
|
|
|
|
var runArchiveDataCommand bool
|
2016-12-08 19:57:44 +00:00
|
|
|
var idArg int
|
2016-12-08 19:45:26 +00:00
|
|
|
var emailArg string
|
|
|
|
var passwordArg string
|
2016-12-08 20:07:24 +00:00
|
|
|
var nArg int
|
2016-12-08 19:45:26 +00:00
|
|
|
|
|
|
|
func Parse() {
|
2016-12-11 13:50:01 +00:00
|
|
|
// parse commands
|
|
|
|
flag.BoolVar(&runCreateUserCommand, "create_user", false, "Create a new user")
|
|
|
|
flag.BoolVar(&runDeleteUserCommand, "delete_user", false, "Deletes a user")
|
|
|
|
flag.BoolVar(&runStartServerCommand, "start_server", true, "Start the API web server")
|
|
|
|
flag.BoolVar(&runSeedDataCommand, "seed_data", false, "Seed the database -n times")
|
|
|
|
flag.BoolVar(&runArchiveDataCommand, "archive_data", false, "Archives data into daily aggregated totals")
|
|
|
|
flag.StringVar(&emailArg, "email", "", "Email address")
|
|
|
|
flag.StringVar(&passwordArg, "password", "", "Password")
|
|
|
|
flag.IntVar(&idArg, "id", 0, "Object ID")
|
|
|
|
flag.IntVar(&nArg, "n", 0, "Number")
|
|
|
|
flag.Parse()
|
2016-12-08 19:45:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Run() {
|
2016-12-11 13:50:01 +00:00
|
|
|
if runCreateUserCommand {
|
|
|
|
createUser()
|
|
|
|
} else if runDeleteUserCommand {
|
|
|
|
deleteUser()
|
|
|
|
} else if runSeedDataCommand {
|
|
|
|
seedData()
|
|
|
|
} else if runArchiveDataCommand {
|
|
|
|
archiveData()
|
|
|
|
} else if runStartServerCommand {
|
|
|
|
startServer()
|
|
|
|
}
|
2016-12-08 19:45:26 +00:00
|
|
|
}
|