From 9ae3559da4f7bd6210654d3e2adfc4ebe4791fe3 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Fri, 12 Apr 2019 11:17:02 -0700 Subject: [PATCH 1/2] add hidden option to specify command name --- src/bin/wasmer.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index cc97810a98f..414099f4067 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -83,6 +83,9 @@ struct Run { #[structopt(long = "em-symbol-map", parse(from_os_str))] em_symbol_map: Option, + #[structopt(long = "command-name", hidden = true)] + command_name: Option, + /// Application arguments #[structopt(name = "--", raw(multiple = "true"))] args: Vec, @@ -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(), @@ -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))?; From 9c12b3f7f130ade140602d6dfb97f272f29af6e5 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Fri, 12 Apr 2019 11:22:01 -0700 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + lib/emscripten/a.txt | 0 lib/emscripten/foo.txt | 0 3 files changed, 1 insertion(+) delete mode 100644 lib/emscripten/a.txt delete mode 100644 lib/emscripten/foo.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index e3d1826c325..3b210c550f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,4 +5,5 @@ 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) - [#349](https://github.com/wasmerio/wasmer/pull/349) Add [CHANGELOG.md](https://github.com/wasmerio/wasmer/blob/master/CHANGELOG.md). diff --git a/lib/emscripten/a.txt b/lib/emscripten/a.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/lib/emscripten/foo.txt b/lib/emscripten/foo.txt deleted file mode 100644 index e69de29bb2d..00000000000