Skip to content

Commit

Permalink
[fud2] Make plugins optional (#2082)
Browse files Browse the repository at this point in the history
Very minor fix: #2078 added plugins, controlled by a `plugins` key in
`fud2.toml`. However, it inadvertently made this option required, i.e.,
fud2 would crash if this option was not present. Now it's optional! So
we just silently proceed with no plugins if none are configured.
  • Loading branch information
sampsyo authored Jun 3, 2024
1 parent 6b8390e commit dd643a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fud2/fud-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ camino = "1.1.6"
anyhow.workspace = true
log.workspace = true
env_logger.workspace = true
rhai = { version = "1.18.0" }
rhai = "1.18.0"
once_cell = "1.19.0"
ariadne = "0.4.1"
10 changes: 8 additions & 2 deletions fud2/fud-core/src/script/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ impl LoadPlugins for DriverBuilder {
fn load_plugins(self) -> Self {
// get list of plugins
let config = config::load_config(&self.name);
let plugin_files =
config.extract_inner::<Vec<PathBuf>>("plugins").unwrap();
let plugin_files = match config.extract_inner::<Vec<PathBuf>>("plugins")
{
Ok(v) => v,
Err(_) => {
// No plugins to load.
return self;
}
};

// wrap driver in a ref cell, so that we can call it from a
// Rhai context
Expand Down

0 comments on commit dd643a8

Please sign in to comment.