-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add builder API for WasiState #850
Conversation
bors r+ |
850: Add builder API for WasiState r=MarkMcCaskey a=MarkMcCaskey Nicer to use and it checks for errors! # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <[email protected]> Co-authored-by: Mark McCaskey <[email protected]>
Build failed
|
lib/wasi/src/state/builder.rs
Outdated
/// Creates an empty [`WasiStateBuilder`]. | ||
pub fn create_wasi_state() -> WasiStateBuilder { | ||
WasiStateBuilder::default() | ||
} | ||
|
||
/// Type for building an instance of [`WasiState`] | ||
/// | ||
/// Usage: | ||
/// | ||
/// ``` | ||
/// # use wasmer_wasi::state::create_wasi_state; | ||
/// create_wasi_state() | ||
/// .env(b"HOME", "/home/home".to_string()) | ||
/// .arg("--help") | ||
/// .envs({ let mut hm = std::collections::HashMap::new(); | ||
/// hm.insert("COLOR_OUTPUT", "TRUE"); | ||
/// hm.insert("PATH", "/usr/bin"); | ||
/// hm | ||
/// }) | ||
/// .args(&["--verbose", "list"]) | ||
/// .preopen_dir("src") | ||
/// .map_dir("dot", ".") | ||
/// .build() | ||
/// .unwrap(); | ||
/// ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that perhaps this API might be simpler? (removing crate_wasi_state
and renaming WasiStateBuilder
to WASICommand
)
use wasmer_wasi::WASICommand;
WASICommand::new("")
.env(b"HOME", "/home/home".to_string())
.arg("--help")
.envs({ let mut hm = std::collections::HashMap::new();
hm.insert("COLOR_OUTPUT", "TRUE");
hm.insert("PATH", "/usr/bin");
hm
})
.args(&["--verbose", "list"])
.preopen_dir("src")
.map_dir("dot", ".")
.build()
.unwrap();
format with 1.37
364b585
to
5185f12
Compare
I'm not implementing the command interface now. I do like it though and it's something I want to revisit. But I think it may not fit in this PR. We could have a general |
bors r+ |
850: Add builder API for WasiState r=MarkMcCaskey a=MarkMcCaskey Nicer to use and it checks for errors! # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <[email protected]> Co-authored-by: Mark McCaskey <[email protected]>
Canceled |
bors r+ |
850: Add builder API for WasiState r=MarkMcCaskey a=MarkMcCaskey Nicer to use and it checks for errors! # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <[email protected]> Co-authored-by: Mark McCaskey <[email protected]>
cbdfd87
to
3c47563
Compare
Canceled |
bors r+ |
850: Add builder API for WasiState r=MarkMcCaskey a=MarkMcCaskey Nicer to use and it checks for errors! # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <[email protected]> Co-authored-by: Mark McCaskey <[email protected]>
Build failed
|
Fix typo Fix debug issue
3c47563
to
afbde49
Compare
bors retry |
850: Add builder API for WasiState r=MarkMcCaskey a=MarkMcCaskey Nicer to use and it checks for errors! # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <[email protected]> Co-authored-by: Mark McCaskey <[email protected]>
Build succeeded
|
Nicer to use and it checks for errors!
Review