Add a del-alias command

This commit is contained in:
Jez Cope 2021-07-03 15:27:07 +01:00
parent 218eef21ee
commit e5ecc80630
2 changed files with 18 additions and 0 deletions

View File

@ -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(())
}

View File

@ -32,6 +32,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
<alias> 'The new alias to add'",
),
)
.subcommand(
SubCommand::with_name("del-alias")
.about("deletes an existing alias")
.args_from_usage("<alias> 'The alias to delete'"),
)
.get_matches();
match matches.subcommand() {
@ -45,6 +50,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
)
.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);