mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 15:21:24 +01:00
wip: skeleton
This commit is contained in:
parent
cbdeff003d
commit
7d5795d868
3 changed files with 37 additions and 0 deletions
22
src/cli.rs
22
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,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
src/cli/delete_room.rs
Normal file
12
src/cli/delete_room.rs
Normal file
|
|
@ -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<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -40,6 +40,9 @@ impl fmt::Display for DisplayWithSources<'_> {
|
|||
#[allow(missing_docs)]
|
||||
#[derive(Error, Debug)]
|
||||
pub(crate) enum Main {
|
||||
#[error(transparent)]
|
||||
DeleteRoomCommand(#[from] Box<dyn std::error::Error>),
|
||||
|
||||
#[error(transparent)]
|
||||
ServeCommand(#[from] ServeCommand),
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue