Added reload <plugin>

This commit is contained in:
2025-12-22 00:40:09 +01:00
parent 83f4e21b2e
commit 113c0628ee
2 changed files with 19 additions and 1 deletions
+15 -1
View File
@@ -122,7 +122,21 @@ pub fn start_cli(server: Arc<Server>, plugin_loader: PluginLoader) {
}
}
"load" "loads a plugin that has been installed" => {
if require_args(&args, &["<plugin-dir>"]) {
if require_args(&args, &["<plugin-id>"]) {
plugin_loader.load(&server.root.join("plugins").join(&args[1]));
}
}
"reload" "restarts a plugin that has been installed" => {
if require_args(&args, &["<plugin-id>"]) {
let target = args[1].as_str();
for plugin in server.plugins.lock().unwrap().iter_mut() {
if plugin.get_id() == target {
LOGGER.info("Stopping plugin");
if let Err(e) = plugin.stop() {
LOGGER.warn(e.context("Couldn't stop plugin"));
}
}
}
plugin_loader.load(&server.root.join("plugins").join(&args[1]));
}
}
+4
View File
@@ -69,4 +69,8 @@ impl Plugin {
self.child.lock().unwrap().kill()?;
Ok(())
}
pub fn get_id(&self) -> String {
self.id.clone()
}
}