add (probably messy) support for hot lib reload via admin command
`!admin test test1` Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
76c5942b4f
commit
b282c1eb6d
6 changed files with 66 additions and 1 deletions
31
src/service/admin/test_cmd/mod.rs
Normal file
31
src/service/admin/test_cmd/mod.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use clap::Subcommand;
|
||||
#[cfg(feature = "hot_reload")]
|
||||
#[allow(unused_imports)]
|
||||
#[allow(clippy::wildcard_imports)]
|
||||
use hot_lib::*;
|
||||
use ruma::events::room::message::RoomMessageEventContent;
|
||||
|
||||
use crate::{debug_error, Result};
|
||||
|
||||
#[cfg(feature = "hot_reload")]
|
||||
#[hot_lib_reloader::hot_module(dylib = "lib")]
|
||||
mod hot_lib {
|
||||
hot_functions_from_file!("lib/src/lib.rs");
|
||||
}
|
||||
|
||||
#[cfg_attr(test, derive(Debug))]
|
||||
#[derive(Subcommand)]
|
||||
pub(crate) enum TestCommands {
|
||||
Test1,
|
||||
}
|
||||
|
||||
pub(crate) async fn process(command: TestCommands, _body: Vec<&str>) -> Result<RoomMessageEventContent> {
|
||||
Ok(match command {
|
||||
TestCommands::Test1 => {
|
||||
debug_error!("before calling test_command");
|
||||
test_command();
|
||||
debug_error!("after calling test_command");
|
||||
RoomMessageEventContent::notice_plain(String::from("loaded"))
|
||||
},
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue