mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-06-26 17:46:36 +02:00
The first part of getting admin command docs on the website. Next is is including it in the same way we do the example config or readme. There's also the beginnings of manpage generation here, although it's kinda sus and I'm not sure how it's supposed to work. I'll leave that to anyone who wants to package it. We introduce the beginings of the xtask pattern here - we do a lot of file generation, I thought it would be best to avoid doing that on every compilation. It also helps avoid lots of runtime deps. We'll need to document generating this stuff & probably add pre-commit hooks for it, though.
42 lines
1.3 KiB
Rust
42 lines
1.3 KiB
Rust
use clap::Subcommand;
|
|
use conduwuit::Result;
|
|
use futures::TryStreamExt;
|
|
|
|
use crate::Context;
|
|
|
|
#[derive(Debug, Subcommand)]
|
|
/// All the getters and iterators from src/database/key_value/appservice.rs
|
|
pub enum AppserviceCommand {
|
|
/// - Gets the appservice registration info/details from the ID as a string
|
|
GetRegistration {
|
|
/// Appservice registration ID
|
|
appservice_id: String,
|
|
},
|
|
|
|
/// - Gets all appservice registrations with their ID and registration info
|
|
All,
|
|
}
|
|
|
|
/// All the getters and iterators from src/database/key_value/appservice.rs
|
|
pub(super) async fn process(subcommand: AppserviceCommand, context: &Context<'_>) -> Result {
|
|
let services = context.services;
|
|
|
|
match subcommand {
|
|
| AppserviceCommand::GetRegistration { appservice_id } => {
|
|
let timer = tokio::time::Instant::now();
|
|
let results = services.appservice.get_registration(&appservice_id).await;
|
|
|
|
let query_time = timer.elapsed();
|
|
|
|
write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
|
|
},
|
|
| AppserviceCommand::All => {
|
|
let timer = tokio::time::Instant::now();
|
|
let results: Vec<_> = services.appservice.iter_db_ids().try_collect().await?;
|
|
let query_time = timer.elapsed();
|
|
|
|
write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
|
|
},
|
|
}
|
|
.await
|
|
}
|