From 0426d8fc7dd14cd8977b1a24a7d7975d27734910 Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Tue, 16 Jan 2024 17:09:15 +0800 Subject: [PATCH] Updated the `wasmer` CLI to pick up the `WasiRunner` API changes --- lib/cli/src/commands/run/mod.rs | 10 ++++++---- lib/wasix/src/runners/wasi.rs | 7 ++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/cli/src/commands/run/mod.rs b/lib/cli/src/commands/run/mod.rs index 41ab50db1fc..edf7d615667 100644 --- a/lib/cli/src/commands/run/mod.rs +++ b/lib/cli/src/commands/run/mod.rs @@ -359,7 +359,9 @@ impl Run { ) -> Result { let packages = self.load_injected_packages(runtime)?; - let mut runner = WasiRunner::new() + let mut runner = WasiRunner::new(); + + runner .with_args(&self.args) .with_injected_packages(packages) .with_envs(self.wasi.env_vars.clone()) @@ -371,10 +373,10 @@ impl Run { #[cfg(feature = "journal")] { for trigger in self.wasi.snapshot_on.iter().cloned() { - runner.add_snapshot_trigger(trigger); + runner.with_snapshot_trigger(trigger); } if self.wasi.snapshot_on.is_empty() && !self.wasi.journals.is_empty() { - runner.add_default_snapshot_triggers(); + runner.with_default_snapshot_triggers(); } if let Some(period) = self.wasi.snapshot_interval { if self.wasi.journals.is_empty() { @@ -385,7 +387,7 @@ impl Run { runner.with_snapshot_interval(Duration::from_millis(period)); } for journal in self.wasi.build_journals()? { - runner.add_journal(journal); + runner.with_journal(journal); } } diff --git a/lib/wasix/src/runners/wasi.rs b/lib/wasix/src/runners/wasi.rs index 86caad76d20..1493feb3d5f 100644 --- a/lib/wasix/src/runners/wasi.rs +++ b/lib/wasix/src/runners/wasi.rs @@ -88,11 +88,13 @@ impl WasiRunner { self } - pub fn mount(&mut self, dest: String, fs: Arc) -> &mut Self { + /// Mount a [`FileSystem`] instance at a particular location. + pub fn with_mount(&mut self, dest: String, fs: Arc) -> &mut Self { self.wasi.mounts.push(MountedDirectory { guest: dest, fs }); self } + /// Override the directory the WASIX instance will start in. pub fn with_current_dir(&mut self, dir: impl Into) -> &mut Self { self.wasi.current_dir = Some(dir.into()); self @@ -198,6 +200,9 @@ impl WasiRunner { self.with_imports([((namespace, name), value)]) } + /// Add multiple import functions. + /// + /// This method will accept a [`&Imports`][wasmer::Imports] object. pub fn with_imports(&mut self, imports: I) -> &mut Self where I: IntoIterator,