Remove dash from admin command help
This commit is contained in:
parent
4bbff69a24
commit
6399a7fe4e
1 changed files with 12 additions and 5 deletions
|
@ -13,7 +13,7 @@ use rocket::{
|
||||||
};
|
};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
events::{room::message::RoomMessageEventContent, EventType},
|
events::{room::message::RoomMessageEventContent, EventType},
|
||||||
EventId, RoomId, RoomVersionId, UserId,
|
EventId, RoomId, RoomVersionId, ServerName, UserId,
|
||||||
};
|
};
|
||||||
use serde_json::value::to_raw_value;
|
use serde_json::value::to_raw_value;
|
||||||
use tokio::sync::{MutexGuard, RwLock, RwLockReadGuard};
|
use tokio::sync::{MutexGuard, RwLock, RwLockReadGuard};
|
||||||
|
@ -140,10 +140,11 @@ fn process_admin_message(db: &Database, room_message: String) -> RoomMessageEven
|
||||||
let admin_command = match parse_admin_command(&command_line) {
|
let admin_command = match parse_admin_command(&command_line) {
|
||||||
Ok(command) => command,
|
Ok(command) => command,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
|
let server_name = db.globals.server_name();
|
||||||
let message = error
|
let message = error
|
||||||
.to_string()
|
.to_string()
|
||||||
.replace("example.com", db.globals.server_name().as_str());
|
.replace("server.name", server_name.as_str());
|
||||||
let html_message = usage_to_html(&message);
|
let html_message = usage_to_html(&message, server_name);
|
||||||
|
|
||||||
return RoomMessageEventContent::text_html(message, html_message);
|
return RoomMessageEventContent::text_html(message, html_message);
|
||||||
}
|
}
|
||||||
|
@ -191,7 +192,7 @@ fn parse_admin_command(command_line: &str) -> std::result::Result<AdminCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(name = "@conduit:example.com", version = env!("CARGO_PKG_VERSION"))]
|
#[clap(name = "@conduit:server.name:", version = env!("CARGO_PKG_VERSION"))]
|
||||||
enum AdminCommand {
|
enum AdminCommand {
|
||||||
#[clap(verbatim_doc_comment)]
|
#[clap(verbatim_doc_comment)]
|
||||||
/// Register an appservice using its registration YAML
|
/// Register an appservice using its registration YAML
|
||||||
|
@ -421,7 +422,13 @@ fn process_admin_command(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utility to turn clap's `--help` text to HTML.
|
// Utility to turn clap's `--help` text to HTML.
|
||||||
fn usage_to_html(text: &str) -> String {
|
fn usage_to_html(text: &str, server_name: &ServerName) -> String {
|
||||||
|
// Replace `@conduit:servername:-subcmdname` with `@conduit:servername: subcmdname`
|
||||||
|
let text = text.replace(
|
||||||
|
&format!("@conduit:{}:-", server_name),
|
||||||
|
&format!("@conduit:{}: ", server_name),
|
||||||
|
);
|
||||||
|
|
||||||
// For the conduit admin room, subcommands become main commands
|
// For the conduit admin room, subcommands become main commands
|
||||||
let text = text.replace("SUBCOMMAND", "COMMAND");
|
let text = text.replace("SUBCOMMAND", "COMMAND");
|
||||||
let text = text.replace("subcommand", "command");
|
let text = text.replace("subcommand", "command");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue