diff --git a/src/ctx.rs b/src/ctx.rs index 580d04d575..66a2e12610 100644 --- a/src/ctx.rs +++ b/src/ctx.rs @@ -3,6 +3,7 @@ use crate::sys::dev_null; use crate::{host, Error, Result}; use std::borrow::Borrow; use std::collections::HashMap; +use std::env; use std::ffi::CString; use std::fs::File; use std::path::{Path, PathBuf}; @@ -45,6 +46,11 @@ impl WasiCtxBuilder { Ok(self) } + /// Inherit the command-line arguments from the host process. + pub fn inherit_args(self) -> Result { + self.args(env::args()) + } + pub fn inherit_stdio(mut self) -> Result { self.fds.insert(0, FdEntry::duplicate_stdin()?); self.fds.insert(1, FdEntry::duplicate_stdout()?);