add `--no-details` to admin rooms list command

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-09-01 00:56:49 -04:00
parent fc1834d629
commit 27bfb67d75
2 changed files with 11 additions and 2 deletions

View File

@ -5,7 +5,7 @@ use crate::{admin_command, get_room_info, PAGE_SIZE};
#[admin_command]
pub(super) async fn list_rooms(
&self, page: Option<usize>, exclude_disabled: bool, exclude_banned: bool,
&self, page: Option<usize>, exclude_disabled: bool, exclude_banned: bool, no_details: bool,
) -> Result<RoomMessageEventContent> {
// TODO: i know there's a way to do this with clap, but i can't seem to find it
let page = page.unwrap_or(1);
@ -63,7 +63,11 @@ pub(super) async fn list_rooms(
rooms.len(),
rooms
.iter()
.map(|(id, members, name)| format!("{id}\tMembers: {members}\tName: {name}"))
.map(|(id, members, name)| if no_details {
format!("{id}")
} else {
format!("{id}\tMembers: {members}\tName: {name}")
})
.collect::<Vec<_>>()
.join("\n")
);

View File

@ -27,6 +27,11 @@ pub(super) enum RoomCommand {
/// Excludes rooms that we have banned
#[arg(long)]
exclude_banned: bool,
#[arg(long)]
/// Whether to only output room IDs without supplementary room
/// information
no_details: bool,
},
#[command(subcommand)]