diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-11-02 22:37:56 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-11-03 17:07:43 +0100 |
commit | 272a73cae03d7c5ae22ff94b935a1d37f437ebef (patch) | |
tree | 9ba694dd16cbe464c5dfe5b25872e131fd880655 | |
parent | 302a24afb2385dcbb161e331cce2ce0826c3c61a (diff) | |
download | rebel-272a73cae03d7c5ae22ff94b935a1d37f437ebef.tar rebel-272a73cae03d7c5ae22ff94b935a1d37f437ebef.zip |
driver: recipe: derive version number from filename
-rw-r--r-- | crates/driver/src/recipe.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/driver/src/recipe.rs b/crates/driver/src/recipe.rs index 0121800..745e2f6 100644 --- a/crates/driver/src/recipe.rs +++ b/crates/driver/src/recipe.rs @@ -60,10 +60,14 @@ pub fn read_recipes<P: AsRef<Path>>(path: P) -> Result<HashMap<TaskID, TaskDef>> continue; } - let basename: &str = match path.file_stem().map(|n| n.to_str()) { + let stem: &str = match path.file_stem().map(|n| n.to_str()) { Some(Some(v)) => v, _ => continue, }; + let (basename, version) = match stem.split_once("@") { + Some((basename, version)) => (basename, Some(version)), + None => (stem, None), + }; let recipe = CURRENT_RECIPE.set(basename, || read_recipe(path))?; @@ -71,6 +75,9 @@ pub fn read_recipes<P: AsRef<Path>>(path: P) -> Result<HashMap<TaskID, TaskDef>> if meta.name.is_empty() { meta.name = basename.to_string(); } + if meta.version.is_none() { + meta.version = version.map(|v| v.to_string()); + } for (label, mut task) in recipe.tasks { let task_id = TaskID { |