mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-19 17:30:17 +00:00
fix(autoconfigure): apply the actions properly in the root
This commit is contained in:
21
src/main.rs
21
src/main.rs
@@ -7,7 +7,7 @@ use crate::entries::BootableEntry;
|
||||
use crate::options::SproutOptions;
|
||||
use crate::options::parser::OptionsRepresentable;
|
||||
use crate::phases::phase;
|
||||
use anyhow::{Context, Result};
|
||||
use anyhow::{Context, Result, bail};
|
||||
use log::info;
|
||||
use std::collections::BTreeMap;
|
||||
use std::ops::Deref;
|
||||
@@ -114,6 +114,25 @@ fn main() -> Result<()> {
|
||||
autoconfigure::autoconfigure(&mut config).context("unable to autoconfigure")?;
|
||||
}
|
||||
|
||||
// Unload the context so that it can be modified.
|
||||
let Some(mut context) = context.unload() else {
|
||||
bail!("context safety violation while trying to unload context");
|
||||
};
|
||||
|
||||
// Perform root context modification in a block to release the modification when complete.
|
||||
{
|
||||
// Modify the root context to include the autoconfigured actions.
|
||||
let Some(root) = context.root_mut() else {
|
||||
bail!("context safety violation while trying to modify root context");
|
||||
};
|
||||
|
||||
// Extend the root context with the autoconfigured actions.
|
||||
root.actions_mut().extend(config.actions);
|
||||
}
|
||||
|
||||
// Refreeze the context to ensure that further operations can share the context.
|
||||
let context = context.freeze();
|
||||
|
||||
// Run all the extractors declared in the configuration.
|
||||
let mut extracted = BTreeMap::new();
|
||||
for (name, extractor) in &config.extractors {
|
||||
|
||||
Reference in New Issue
Block a user