Skip to content

Commit

Permalink
feat: add debug option for plugin manager
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 17, 2021
1 parent 071e717 commit 2a85b65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/app/plugin_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct PluginManager {
}

impl PluginManager {
pub fn run(&self, plugin_name: &str) {
pub fn run(&self, plugin_name: &str, is_debug: bool) {
let root = PathBuf::from(".");
let production_plugins = root.join("coco_plugins");

Expand All @@ -35,7 +35,9 @@ impl PluginManager {
path = debug_root.join(plugin_path);
}

println!("search plugins in path: {:?}", path.display());
if is_debug {
println!("search plugins in path: {:?}", path.display());
}

let cont: Container<Wrapper> =
unsafe { Container::load(path) }.expect("Could not open library or load symbols");
Expand All @@ -47,12 +49,12 @@ impl PluginManager {
plugin.execute(self.config.clone());
}

pub fn run_all(&self) {
pub fn run_all(&self, is_debug: bool) {
if self.config.plugins.is_none() {
return ();
}
for plugin in self.config.plugins.as_ref().unwrap().iter() {
self.run(&plugin.name);
self.run(&plugin.name, is_debug);
}
}

Expand Down Expand Up @@ -113,7 +115,7 @@ mod tests {
config.plugins = Some(plugins);

let manager = PluginManager::from(&config);
manager.run_all();
manager.run_all(false);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/bin/coco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn main() {
analyst.analysis(opt);

let plugin_manager = PluginManager::from(&config);
plugin_manager.run_all();
plugin_manager.run_all(opt.debug.clone());
}

fn create_config_file() {
Expand Down

0 comments on commit 2a85b65

Please sign in to comment.