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