Skip to main content

tuwunel_admin/
admin.rs

1use clap::Parser;
2use tuwunel_core::Result;
3
4use crate::{
5	appservice::{self, AppserviceCommand},
6	context::Context,
7	debug::{self, DebugCommand},
8	federation::{self, FederationCommand},
9	media::{self, MediaCommand},
10	query::{self, QueryCommand},
11	room::{self, RoomCommand},
12	server::{self, ServerCommand},
13	token::{self, TokenCommand},
14	user::{self, UserCommand},
15};
16
17#[derive(Debug, Parser)]
18#[command(name = "tuwunel", version = tuwunel_core::version())]
19pub(super) enum AdminCommand {
20	#[command(subcommand)]
21	/// - Commands for managing appservices
22	Appservices(AppserviceCommand),
23
24	#[command(subcommand)]
25	/// - Commands for managing local users
26	Users(UserCommand),
27
28	#[command(subcommand)]
29	/// - Commands for managing rooms
30	Rooms(RoomCommand),
31
32	#[command(subcommand)]
33	/// - Commands for managing federation
34	Federation(FederationCommand),
35
36	#[command(subcommand)]
37	/// - Commands for managing the server
38	Server(ServerCommand),
39
40	#[command(subcommand)]
41	/// - Commands for managing media
42	Media(MediaCommand),
43
44	#[command(subcommand)]
45	/// - Commands for debugging things
46	Debug(DebugCommand),
47
48	#[command(subcommand)]
49	/// - Low-level queries for database getters and iterators
50	Query(QueryCommand),
51
52	#[command(subcommand)]
53	/// - Commands for managing registration tokens
54	Token(TokenCommand),
55}
56
57#[tracing::instrument(skip_all, name = "command")]
58pub(super) async fn process(command: AdminCommand, context: &Context<'_>) -> Result {
59	use AdminCommand::*;
60
61	match command {
62		| Appservices(command) => appservice::process(command, context).await,
63		| Media(command) => media::process(command, context).await,
64		| Users(command) => user::process(command, context).await,
65		| Rooms(command) => room::process(command, context).await,
66		| Federation(command) => federation::process(command, context).await,
67		| Server(command) => server::process(command, context).await,
68		| Debug(command) => debug::process(command, context).await,
69		| Query(command) => query::process(command, context).await,
70		| Token(command) => token::process(command, context).await,
71	}
72}