Skip to content

Commit

Permalink
Merge #351
Browse files Browse the repository at this point in the history
351: add hidden option to specify command name r=MarkMcCaskey a=MarkMcCaskey



Co-authored-by: Mark McCaskey <mark@wasmer.io>
Co-authored-by: Mark McCaskey <markmccaskey@users.noreply.github.com>
  • Loading branch information
3 people committed Apr 12, 2019
2 parents e6e3ba5 + 73be6c7 commit 97059a1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ All PRs to the Wasmer repository must add to this file.
Blocks of changes will separated by version increments.

## **[Unreleased]**
- [#351](https://github.com/wasmerio/wasmer/pull/351) Add hidden option to specify wasm program name (can be used to improve error messages)
- [#350](https://github.com/wasmerio/wasmer/pull/350) Enforce that CHANGELOG.md is updated through CI.
- [#349](https://github.com/wasmerio/wasmer/pull/349) Add [CHANGELOG.md](https://github.com/wasmerio/wasmer/blob/master/CHANGELOG.md).
Empty file removed lib/emscripten/a.txt
Empty file.
Empty file removed lib/emscripten/foo.txt
Empty file.
25 changes: 18 additions & 7 deletions src/bin/wasmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ struct Run {
#[structopt(long = "em-symbol-map", parse(from_os_str))]
em_symbol_map: Option<PathBuf>,

#[structopt(long = "command-name", hidden = true)]
command_name: Option<String>,

/// Application arguments
#[structopt(name = "--", raw(multiple = "true"))]
args: Vec<String>,
Expand Down Expand Up @@ -300,12 +303,16 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
(
InstanceABI::WASI,
wasmer_wasi::generate_import_object(
[options.path.to_str().unwrap().to_owned()]
.iter()
.chain(options.args.iter())
.cloned()
.map(|arg| arg.into_bytes())
.collect(),
if let Some(cn) = &options.command_name {
[cn.clone()]
} else {
[options.path.to_str().unwrap().to_owned()]
}
.iter()
.chain(options.args.iter())
.cloned()
.map(|arg| arg.into_bytes())
.collect(),
env::vars()
.map(|(k, v)| format!("{}={}", k, v).into_bytes())
.collect(),
Expand All @@ -329,7 +336,11 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
&module,
&mut instance,
abi,
options.path.to_str().unwrap(),
if let Some(cn) = &options.command_name {
cn
} else {
options.path.to_str().unwrap()
},
options.args.iter().map(|arg| arg.as_str()).collect(),
)
.map_err(|e| format!("{:?}", e))?;
Expand Down

0 comments on commit 97059a1

Please sign in to comment.