diff options
Diffstat (limited to 'crates/rebel/src/recipe.rs')
-rw-r--r-- | crates/rebel/src/recipe.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/crates/rebel/src/recipe.rs b/crates/rebel/src/recipe.rs index fd5367a..24b4bff 100644 --- a/crates/rebel/src/recipe.rs +++ b/crates/rebel/src/recipe.rs @@ -74,24 +74,25 @@ fn recipe_name(path: &Path) -> Option<&str> { } fn handle_recipe_tasks( - tasks: &mut HashMap<TaskID, Vec<TaskDef>>, + tasks: &mut HashMap<String, HashMap<String, Vec<TaskDef>>>, recipe_tasks: HashMap<String, TaskDef>, meta: &TaskMeta, ) { + let task_map = match tasks.get_mut(&meta.recipe) { + Some(task_map) => task_map, + None => tasks.entry(meta.recipe.clone()).or_default(), + }; + for (label, mut task) in recipe_tasks { - let task_id = TaskID { - recipe: meta.recipe.clone(), - task: label, - }; task.meta = meta.clone(); - tasks.entry(task_id).or_default().push(task); + task_map.entry(label).or_default().push(task); } } fn read_recipe_tasks( path: &Path, basename: &str, - tasks: &mut HashMap<TaskID, Vec<TaskDef>>, + tasks: &mut HashMap<String, HashMap<String, Vec<TaskDef>>>, ) -> Result<RecipeMeta> { let recipe_def = CURRENT_RECIPE.set(basename, || read_yaml::<Recipe>(path))?; @@ -120,7 +121,7 @@ fn read_subrecipe_tasks( basename: &str, recipename: &str, recipe_meta: &RecipeMeta, - tasks: &mut HashMap<TaskID, Vec<TaskDef>>, + tasks: &mut HashMap<String, HashMap<String, Vec<TaskDef>>>, ) -> Result<()> { let recipe = format!("{basename}/{recipename}"); let recipe_def = CURRENT_RECIPE.set(&recipe, || read_yaml::<Subrecipe>(path))?; @@ -140,8 +141,10 @@ fn read_subrecipe_tasks( Ok(()) } -pub fn read_recipes<P: AsRef<Path>>(path: P) -> Result<HashMap<TaskID, Vec<TaskDef>>> { - let mut tasks = HashMap::<TaskID, Vec<TaskDef>>::new(); +pub fn read_recipes<P: AsRef<Path>>( + path: P, +) -> Result<HashMap<String, HashMap<String, Vec<TaskDef>>>> { + let mut tasks = HashMap::<String, HashMap<String, Vec<TaskDef>>>::new(); let mut recipe_metas = HashMap::<String, RecipeMeta>::new(); for entry in WalkDir::new(path) |