hook run command up to both wasi snapshots

sharing the same context! at long last
This commit is contained in:
Pat Hickey
2021-01-29 12:29:30 -08:00
parent 70f8288ec9
commit e498888732
4 changed files with 41 additions and 22 deletions

View File

@@ -25,6 +25,13 @@ impl WasiCtxBuilder {
let s = self.0.env(var, value)?;
Ok(WasiCtxBuilder(s))
}
pub fn envs(self, env: &[(String, String)]) -> Result<Self, wasi_common::StringArrayError> {
let mut s = self;
for (k, v) in env {
s = s.env(k, v)?;
}
Ok(s)
}
pub fn inherit_env(self) -> Result<Self, wasi_common::StringArrayError> {
let mut s = self.0;
for (key, value) in std::env::vars() {
@@ -36,6 +43,13 @@ impl WasiCtxBuilder {
let s = self.0.arg(arg)?;
Ok(WasiCtxBuilder(s))
}
pub fn args(self, arg: &[String]) -> Result<Self, wasi_common::StringArrayError> {
let mut s = self;
for a in arg {
s = s.arg(&a)?;
}
Ok(s)
}
pub fn stdin(self, f: Box<dyn WasiFile>) -> Self {
WasiCtxBuilder(self.0.stdin(f))
}