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);