effect: add toolchain::register for recipes that arrive as text
commit
63502a8effect: add toolchain::register for recipes that arrive as text
import delegates to it after its directory walk; a web form or future CLI flag can now record a parsed Recipe without a local path.
Assisted-by: Claude:claude-fable-5
Reviews
No reviews of this commit yet — record a verdict below.
Start a review
crates/kiln/ents-kiln/src/toolchain/command.rs
@@ -79,7 +79,38 @@
mode: Mode,
) -> Result<Outcome> {
let tree = write_dir_as_tree(bin, objects)?;
- let recipe = Recipe::Embedded { tree };
+ register(
+ refs,
+ objects,
+ events,
+ name,
+ &Recipe::Embedded { tree },
+ identity,
+ mode,
+ )
+}
+
+/// Record toolchain `name` from an already-parsed [`Recipe`] -- the
+/// counterpart of [`import`] for a recipe that arrives as text
+/// ([`Recipe::parse`], say from a web form) rather than as a local
+/// directory to embed; [`import`] itself delegates here once its
+/// directory walk has produced the embedded tree.
+///
+/// Returns the raw [`Outcome`] `receive` reached, as [`import`] does.
+///
+/// # Errors
+///
+/// [`Error::InvalidToolchainName`] if `name` cannot form a ref;
+/// otherwise propagates serialization or `receive` failures.
+pub fn register(
+ refs: &dyn RefStore,
+ objects: &(impl Find + Write),
+ events: &dyn EventSink,
+ name: &str,
+ recipe: &Recipe,
+ identity: &Identity<'_>,
+ mode: Mode,
+) -> Result<Outcome> {
let toolchain = Toolchain {
name: name.to_owned(),
recipe: recipe.render(),
crates/kiln/ents-kiln/src/toolchain/mod.rs
@@ -12,6 +12,6 @@
mod recipe;
pub use cli::ToolchainAction;
-pub use command::{import, list, log, view};
+pub use command::{import, list, log, register, view};
pub use entity::Toolchain;
pub use recipe::{Component, Recipe, cache_key, materialize, resolve};