Add logout command
This commit is contained in:
parent
9a14cb6c90
commit
1c5565e0fb
@ -31,7 +31,7 @@ pub async fn prompt(client: Client) -> anyhow::Result<()> {
|
||||
if let Some(cmd) = args.get(0) {
|
||||
match cmd.as_ref() {
|
||||
"help" => {
|
||||
println!("help; stop; rooms; join room_id; leave room_id");
|
||||
println!("help; stop; logout; rooms; join room_id; leave room_id");
|
||||
},
|
||||
"stop" => {
|
||||
let should_stop = unsafe { crate::SHOULD_STOP.get_mut() };
|
||||
@ -40,6 +40,19 @@ pub async fn prompt(client: Client) -> anyhow::Result<()> {
|
||||
eprintln!("Stopping...");
|
||||
}
|
||||
},
|
||||
"logout" => {
|
||||
match client.logout().await {
|
||||
Ok(_) => {
|
||||
println!("Logged out.");
|
||||
match std::fs::remove_dir_all(crate::DATA_DIR.to_owned()) {
|
||||
Ok(_) => (),
|
||||
Err(e) => anyhow::bail!("Couldn't remove data dir: {e}"),
|
||||
}
|
||||
std::process::exit(0);
|
||||
},
|
||||
Err(e) => anyhow::bail!("Failed to logout: {e}")
|
||||
}
|
||||
},
|
||||
"rooms" => {
|
||||
let rooms = client.rooms();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user