-c now uses db-lib as its backend
also updated the error messages to help out server owners a bit
This commit is contained in:
parent
c6d8e3d360
commit
75fcd5aef5
@ -207,9 +207,25 @@ OPTIONS:
|
||||
if let Some(owner_name) = args.value_of("create-owner") {
|
||||
let p = Pool::new(&env::var("DATABASE_URL").unwrap());
|
||||
eprintln!("Creating owner {{ {} }}...", owner_name);
|
||||
if let Ok(owner) = members::insert_new_member(&p, owner_name.to_string(), std::u64::MAX).await {
|
||||
println!("{}", serde_json::to_string(&owner).unwrap());
|
||||
let owner_secret = auth::generate_secret();
|
||||
// creation of owner should just dump straight to stdout since this fires
|
||||
// from a commandline parameter anyway
|
||||
match db::member::Member::add(&p, &owner_secret, "owner sama uwu", perms::OWNER).await {
|
||||
Ok(response) => {
|
||||
match response {
|
||||
db::Response::Row(owner) =>
|
||||
println!("{}", serde_json::to_string(&owner).expect("SQL query passed but serde couldn't parse the data for some reason")),
|
||||
db::Response::Empty => {
|
||||
eprintln!("SQL server failed to return owner data, check configs and also the members table to make sure there's nothing there by accident");
|
||||
},
|
||||
_ => {}
|
||||
};
|
||||
},
|
||||
Err(_) => {
|
||||
eprintln!("Could not communicate with the SQL server, check your configs!");
|
||||
}
|
||||
}
|
||||
//println!("{}", serde_json::to_string(&owner).unwrap());
|
||||
p.disconnect();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user