diff --git a/src/cli.rs b/src/cli.rs index 99641790..552df6b6 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -6,6 +6,7 @@ use std::path::PathBuf; use clap::{Parser, Subcommand}; +use ruma::OwnedRoomId; use crate::{ config::{default_tracing_filter, EnvFilterClone, LogFormat}, @@ -13,6 +14,7 @@ use crate::{ }; mod check_config; +mod delete_room; mod serve; /// Command line arguments @@ -28,6 +30,9 @@ pub(crate) struct Args { #[derive(Subcommand)] pub(crate) enum Command { + /// Delete a room from the database. + DeleteRoom(DeleteRoomArgs), + /// Run the server. Serve(ServeArgs), @@ -88,6 +93,18 @@ pub(crate) struct ServeArgs { pub(crate) config: ConfigArg, } +#[derive(clap::Args)] +pub(crate) struct DeleteRoomArgs { + #[clap(flatten)] + pub(crate) config: ConfigArg, + + #[clap(flatten)] + observability: ObservabilityArgs, + + /// The room ID to delete all data for + pub(crate) room_id: OwnedRoomId, +} + impl Args { pub(crate) async fn run(self) -> Result<(), error::Main> { if let Some((format, filter)) = self.command.cli_observability_args() { @@ -95,6 +112,7 @@ impl Args { } match self.command { + Command::DeleteRoom(args) => delete_room::run(args).await?, Command::Serve(args) => serve::run(args).await?, Command::CheckConfig(args) => { check_config::run(args.config).await?; @@ -113,6 +131,10 @@ impl Command { args.observability.log_format, args.observability.log_filter.clone(), )), + Command::DeleteRoom(args) => Some(( + args.observability.log_format, + args.observability.log_filter.clone(), + )), Command::Serve(_) => None, } } diff --git a/src/cli/delete_room.rs b/src/cli/delete_room.rs new file mode 100644 index 00000000..e5fc677b --- /dev/null +++ b/src/cli/delete_room.rs @@ -0,0 +1,12 @@ +#![warn(clippy::missing_docs_in_private_items)] + +//! Implementation of the `delete-room` subcommand + +use std::error::Error; + +use super::DeleteRoomArgs; + +/// Subcommand entrypoint +pub(crate) async fn run(args: DeleteRoomArgs) -> Result<(), Box> { + Ok(()) +} diff --git a/src/error.rs b/src/error.rs index ce8ebb37..cd206ab4 100644 --- a/src/error.rs +++ b/src/error.rs @@ -40,6 +40,9 @@ impl fmt::Display for DisplayWithSources<'_> { #[allow(missing_docs)] #[derive(Error, Debug)] pub(crate) enum Main { + #[error(transparent)] + DeleteRoomCommand(#[from] Box), + #[error(transparent)] ServeCommand(#[from] ServeCommand),