Add version info chat command

This commit is contained in:
NG (Graham) committed 2025-09-14 12:23:46 -04:00
1 parent 525fa8b87e
commit c9f9d146e8
6 files changed
+29

No files matched your search

Generated
+1
View File
@@ -2669,6 +2669,7 @@ dependencies = [
"async-trait", "async-trait",
"clap", "clap",
"env_logger", "env_logger",
"git-version",
"log", "log",
"oj_polariton_auth", "oj_polariton_auth",
"oj_rc_core", "oj_rc_core",
+7
View File
@@ -14463,6 +14463,13 @@
"built_in": "TotalUsers" "built_in": "TotalUsers"
} }
}, },
{
"regex": "\\?version",
"op": {
"type": "BuiltIn",
"built_in": "Version"
}
},
{ {
"regex": "\\?help", "regex": "\\?help",
"op": { "op": {
+1
View File
@@ -20,3 +20,4 @@ serde.workspace = true
serde_json.workspace = true serde_json.workspace = true
regex = "1" regex = "1"
async-trait.workspace = true async-trait.workspace = true
git-version.workspace = true
+12
View File
@@ -109,6 +109,7 @@ impl ChatOperation {
enum BuiltIn { enum BuiltIn {
OnlineUsers, OnlineUsers,
TotalUsers, TotalUsers,
Version,
Help, Help,
} }
@@ -117,6 +118,7 @@ impl BuiltIn {
match b_in { match b_in {
oj_rc_core::persist::BuiltInChatOperation::OnlineUsers => Self::OnlineUsers, oj_rc_core::persist::BuiltInChatOperation::OnlineUsers => Self::OnlineUsers,
oj_rc_core::persist::BuiltInChatOperation::TotalUsers => Self::TotalUsers, oj_rc_core::persist::BuiltInChatOperation::TotalUsers => Self::TotalUsers,
oj_rc_core::persist::BuiltInChatOperation::Version => Self::Version,
oj_rc_core::persist::BuiltInChatOperation::Help => Self::Help, oj_rc_core::persist::BuiltInChatOperation::Help => Self::Help,
} }
} }
@@ -145,6 +147,15 @@ impl BuiltIn {
Err(e) => e.error_msg().map(|x| x.to_owned()).unwrap_or_else(|| "Failed to retrieve registered users".to_owned()), Err(e) => e.error_msg().map(|x| x.to_owned()).unwrap_or_else(|| "Failed to retrieve registered users".to_owned()),
} }
}, },
Self::Version => {
let name = env!("CARGO_PKG_NAME");
let version = env!("CARGO_PKG_VERSION");
let git_version = git_version::git_version!(args = ["--always", "--dirty=+"]);
let authors = env!("CARGO_PKG_AUTHORS");
let license = env!("CARGO_PKG_LICENSE");
let repo = env!("CARGO_PKG_REPOSITORY");
format!("{} {}:{}\n[{}]\n{} {}", name, version, git_version, authors, license, repo)
}
Self::Help => { Self::Help => {
use core::fmt::Write; use core::fmt::Write;
let mut msg = String::new(); let mut msg = String::new();
@@ -164,6 +175,7 @@ impl BuiltIn {
match self { match self {
Self::OnlineUsers => "Show total users online".to_owned(), Self::OnlineUsers => "Show total users online".to_owned(),
Self::TotalUsers => "Show total users registered".to_owned(), Self::TotalUsers => "Show total users registered".to_owned(),
Self::Version => "Show chat server version information".to_owned(),
Self::Help => "Display this message".to_owned(), Self::Help => "Display this message".to_owned(),
} }
} }
+1
View File
@@ -33,6 +33,7 @@ pub enum ChatOperation {
pub enum BuiltInChatOperation { pub enum BuiltInChatOperation {
OnlineUsers, OnlineUsers,
TotalUsers, TotalUsers,
Version,
Help, Help,
} }
+7
View File
@@ -474,6 +474,13 @@ def main(asset_in, cubes=None, weapons=None, movement=None):
"built_in": "TotalUsers" "built_in": "TotalUsers"
} }
}, },
{
"regex": "\\?version",
"op": {
"type": "BuiltIn",
"built_in": "Version"
}
},
{ {
"regex": "\\?help", "regex": "\\?help",
"op": { "op": {