Skip to content
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

Merged
merged 6 commits into from Oct 2, 2019
Merged

Conversation

MarkMcCaskey
Copy link
Contributor

Nicer to use and it checks for errors!

Review

  • Add a short description of the the change to the CHANGELOG.md file

@MarkMcCaskey MarkMcCaskey added the 📦 lib-wasi About wasmer-wasi label Sep 30, 2019
@MarkMcCaskey
Copy link
Contributor Author

bors r+

bors bot added a commit that referenced this pull request Oct 1, 2019
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 <mark@wasmer.io>
Co-authored-by: Mark McCaskey <markmccaskey@users.noreply.github.com>
@bors
Copy link
Contributor

bors bot commented Oct 1, 2019

Build failed

  • wasmerio.wasmer

Comment on lines 6 to 30
/// 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();
/// ```
Copy link
Member

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();

@MarkMcCaskey MarkMcCaskey force-pushed the feature/builder-api-for-wasi-state branch from 364b585 to 5185f12 Compare October 2, 2019 18:26
@MarkMcCaskey
Copy link
Contributor Author

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 Wasm command like structure that applies beyond WASI for constructing the Instance. Something to think about, but I do think having an API path that's extremely simple is what we want.

@MarkMcCaskey
Copy link
Contributor Author

bors r+

bors bot added a commit that referenced this pull request Oct 2, 2019
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 <mark@wasmer.io>
Co-authored-by: Mark McCaskey <markmccaskey@users.noreply.github.com>
@bors
Copy link
Contributor

bors bot commented Oct 2, 2019

Canceled

@MarkMcCaskey
Copy link
Contributor Author

bors r+

bors bot added a commit that referenced this pull request Oct 2, 2019
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 <mark@wasmer.io>
Co-authored-by: Mark McCaskey <markmccaskey@users.noreply.github.com>
@MarkMcCaskey MarkMcCaskey force-pushed the feature/builder-api-for-wasi-state branch from cbdfd87 to 3c47563 Compare October 2, 2019 19:23
@bors
Copy link
Contributor

bors bot commented Oct 2, 2019

Canceled

@MarkMcCaskey
Copy link
Contributor Author

bors r+

bors bot added a commit that referenced this pull request Oct 2, 2019
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 <mark@wasmer.io>
Co-authored-by: Mark McCaskey <markmccaskey@users.noreply.github.com>
@bors
Copy link
Contributor

bors bot commented Oct 2, 2019

Build failed

  • wasmerio.wasmer

@MarkMcCaskey MarkMcCaskey force-pushed the feature/builder-api-for-wasi-state branch from 3c47563 to afbde49 Compare October 2, 2019 20:17
@MarkMcCaskey
Copy link
Contributor Author

bors retry

bors bot added a commit that referenced this pull request Oct 2, 2019
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 <mark@wasmer.io>
Co-authored-by: Mark McCaskey <markmccaskey@users.noreply.github.com>
@bors
Copy link
Contributor

bors bot commented Oct 2, 2019

Build succeeded

  • wasmerio.wasmer

@bors bors bot merged commit afbde49 into master Oct 2, 2019
@bors bors bot deleted the feature/builder-api-for-wasi-state branch October 2, 2019 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 lib-wasi About wasmer-wasi
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants