Make commands plural

This commit is contained in:
tezlm 2023-10-14 06:33:29 -07:00
parent 73ef497609
commit fbd8780600
Signed by: tezlm
GPG key ID: 649733FCD94AFBBA

View file

@ -40,19 +40,18 @@ const PAGE_SIZE: usize = 100;
#[cfg_attr(test, derive(Debug))]
#[derive(Parser)]
#[command(name = "@conduit:server.name:", version = env!("CARGO_PKG_VERSION"))]
// TODO: bikeshedding - should command names be singular or plural
enum AdminCommand {
#[command(subcommand)]
/// Commands for managing appservices
Appservice(AppserviceCommand),
Appservices(AppserviceCommand),
#[command(subcommand)]
/// Commands for managing local users
User(UserCommand),
Users(UserCommand),
#[command(subcommand)]
/// Commands for managing rooms
Room(RoomCommand),
Rooms(RoomCommand),
#[command(subcommand)]
/// Commands for managing federation
@ -230,7 +229,6 @@ enum RoomDirectoryCommand {
},
/// List rooms that are published
// TODO: is this really necessary?
List { page: Option<usize> },
}
@ -483,7 +481,7 @@ impl Service {
sender: &UserId,
) -> Result<RoomMessageEventContent> {
let reply_message_content = match command {
AdminCommand::Appservice(command) => match command {
AdminCommand::Appservices(command) => match command {
AppserviceCommand::Register => {
if body.len() > 2
&& body[0].trim().starts_with("```")
@ -556,7 +554,7 @@ impl Service {
RoomMessageEventContent::text_plain(output)
}
},
AdminCommand::User(command) => match command {
AdminCommand::Users(command) => match command {
UserCommand::List => match services().users.list_local_users() {
Ok(users) => {
let mut msg: String =
@ -756,7 +754,7 @@ impl Service {
}
}
},
AdminCommand::Room(command) => match command {
AdminCommand::Rooms(command) => match command {
RoomCommand::List { page } => {
// 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);
@ -822,7 +820,6 @@ impl Service {
);
RoomMessageEventContent::text_html(output_plain, output_html)
}
// TODO: clean up and deduplicate code
RoomCommand::Alias(command) => match command {
RoomAliasCommand::Set {
ref room_alias_localpart,