From e5ecc80630e65bbccdb2f3fe3f6e6d6770f7c016 Mon Sep 17 00:00:00 2001 From: Jez Cope Date: Sat, 3 Jul 2021 15:27:07 +0100 Subject: [PATCH] Add a del-alias command --- src/commands.rs | 10 ++++++++++ src/main.rs | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/commands.rs b/src/commands.rs index 7da8031..302385a 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -104,3 +104,13 @@ pub async fn add_alias(room_id: &str, alias: &str) -> CommandResult { Ok(()) } + +pub async fn del_alias(alias: &str) -> CommandResult { + let alias_id = RoomAliasId::try_from(alias)?; + let client = restore_session().await?; + + let request = alias::delete_alias::Request::new(&alias_id); + client.send(request, None).await?; + + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index 6cf39cf..b785121 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,6 +32,11 @@ async fn main() -> Result<(), Box> { 'The new alias to add'", ), ) + .subcommand( + SubCommand::with_name("del-alias") + .about("deletes an existing alias") + .args_from_usage(" 'The alias to delete'"), + ) .get_matches(); match matches.subcommand() { @@ -45,6 +50,9 @@ async fn main() -> Result<(), Box> { ) .await? } + ("del-alias", Some(submatches)) => { + commands::del_alias(submatches.value_of("alias").unwrap()).await? + } ("", None) => eprintln!("No subcommand given"), (c, _) => { todo!("Subcommand '{}' not implemented yet!", c);