From 27bfb67d753aa7f8408d00eee484348e95f433e8 Mon Sep 17 00:00:00 2001 From: strawberry Date: Sun, 1 Sep 2024 00:56:49 -0400 Subject: [PATCH] add `--no-details` to admin rooms list command Signed-off-by: strawberry --- src/admin/room/commands.rs | 8 ++++++-- src/admin/room/mod.rs | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/admin/room/commands.rs b/src/admin/room/commands.rs index fff5e5b6..2adfa7d7 100644 --- a/src/admin/room/commands.rs +++ b/src/admin/room/commands.rs @@ -5,7 +5,7 @@ use crate::{admin_command, get_room_info, PAGE_SIZE}; #[admin_command] pub(super) async fn list_rooms( - &self, page: Option, exclude_disabled: bool, exclude_banned: bool, + &self, page: Option, exclude_disabled: bool, exclude_banned: bool, no_details: bool, ) -> Result { // 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::>() .join("\n") ); diff --git a/src/admin/room/mod.rs b/src/admin/room/mod.rs index da7acb80..64d2af45 100644 --- a/src/admin/room/mod.rs +++ b/src/admin/room/mod.rs @@ -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)]