diff --git a/src/main.rs b/src/main.rs index 7216dda8..4922fce9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,7 +30,6 @@ use data::kv::KV; use router::Routes; use std::io::{Error, ErrorKind}; use std::path::PathBuf; -use std::process::exit; use std::{collections::HashMap, sync::RwLock}; use workers::wasm_io::WasmOutput; @@ -225,38 +224,40 @@ async fn main() -> std::io::Result<()> { // Check the given subcommand if let Some(Main::Runtimes(sub)) = &args.commands { + let mut run_result = Ok(()); + match &sub.runtime_commands { RuntimesCommands::List(list) => { if let Err(err) = list.run(sub).await { println!("❌ There was an error listing the runtimes from the repository"); println!("👉 {err}"); - exit(1); + run_result = Err(Error::new(ErrorKind::InvalidData, "")); } } RuntimesCommands::Install(install) => { if let Err(err) = install.run(&args.path, sub).await { println!("❌ There was an error installing the runtime from the repository"); println!("👉 {err}"); - exit(1); + run_result = Err(Error::new(ErrorKind::InvalidData, "")); } } RuntimesCommands::Uninstall(uninstall) => { if let Err(err) = uninstall.run(&args.path, sub) { println!("❌ There was an error uninstalling the runtime"); println!("👉 {err}"); - exit(1); + run_result = Err(Error::new(ErrorKind::InvalidData, "")); } } RuntimesCommands::Check(check) => { if let Err(err) = check.run(&args.path) { println!("❌ There was an error checking the local runtimes"); println!("👉 {err}"); - exit(1); + run_result = Err(Error::new(ErrorKind::InvalidData, "")); } } }; - Ok(()) + run_result } else { // TODO(Angelmmiguel): refactor this into a separate command! // Initialize the routes diff --git a/src/runtimes/metadata.rs b/src/runtimes/metadata.rs index e142d1c4..a7b2f5b4 100644 --- a/src/runtimes/metadata.rs +++ b/src/runtimes/metadata.rs @@ -164,7 +164,7 @@ impl Checksum { pub fn validate(&self, bytes: &[u8]) -> Result<()> { match self { Checksum::Sha256 { value } if value == &sha256_digest(bytes) => Ok(()), - _ => Err(anyhow!("The checksums dont not match")), + _ => Err(anyhow!("The checksums don't match")), } } }