Skip to content

Commit

Permalink
Merge #3402
Browse files Browse the repository at this point in the history
3402: Do not run first command of wapm file and print all commands instead r=fschutt a=fschutt

Fixes #3345.

Co-authored-by: Felix Schütt <felix@wasmer.io>
Co-authored-by: Felix Schütt <12084016+fschutt@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 2, 2022
2 parents b3ea89b + 9443b2a commit 01daa24
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,20 @@ pub fn get_executable_file_from_path(
Some(s) => commands.iter().find(|c| c.get_name() == s).ok_or_else(|| {
anyhow::anyhow!("Cannot run {name}@{version}: package has no command {s:?}")
})?,
None => commands.first().ok_or_else(|| {
anyhow::anyhow!("Cannot run {name}@{version}: package has no commands")
})?,
None => {
if commands.is_empty() {
Err(anyhow::anyhow!(
"Cannot run {name}@{version}: package has no commands"
))
} else if commands.len() == 1 {
Ok(&commands[0])
} else {
Err(anyhow::anyhow!(" -> wasmer run {name}@{version} --command-name={0} OR wasmer run {name}@{version}:{0}", commands.first().map(|f| f.get_name()).unwrap()))
.context(anyhow::anyhow!("{}", commands.iter().map(|c| format!("`{}`", c.get_name())).collect::<Vec<_>>().join(", ")))
.context(anyhow::anyhow!("You can run any of those by using the --command-name=COMMAND flag or : postfix"))
.context(anyhow::anyhow!("The `{name}@{version}` package doesn't have a default entrypoint, but has multiple available commands:"))
}?
}
};

let module_name = entrypoint_module.get_module();
Expand Down

0 comments on commit 01daa24

Please sign in to comment.