main: Make ouch return 1 upon failure

This commit is contained in:
Vinícius Rodrigues Miguel 2021-03-25 21:43:45 -03:00
parent c14874072d
commit ceb507fd14

View File

@ -11,37 +11,22 @@ mod utils;
mod compressors;
mod decompressors;
use evaluator::Evaluator;
fn main() -> error::OuchResult<()> {
let print_error = |err| {
println!("{}", err);
err
};
let matches = cli::get_matches();
cli::Command::try_from(matches)
.map(|command| evaluator::Evaluator::evaluate(command).unwrap_or_else(print_error))
.unwrap_or_else(print_error);
let command = match cli::Command::try_from(matches) {
Ok(command) => command,
Err(err) => return Err(print_error(err))
};
Ok(())
match Evaluator::evaluate(command) {
Ok(_) => Ok(()),
Err(err) => Err(print_error(err))
}
}
// fn main() -> error::OuchResult<()> {
// use tar::{Builder};
// use walkdir::WalkDir;
//
// let mut b = Builder::new(Vec::new());
//
// for entry in WalkDir::new("src") {
// let entry = entry?;
// let mut file = std::fs::File::open(entry.path())?;
// b.append_file(entry.path(), &mut file)?;
// }
//
// // let mut file = std::fs::File::open("Cargo.toml")?;
// // b.append_file("Cargo.toml", &mut file)?;
//
// let bytes = b.into_inner()?;
//
// std::fs::write("daaaaamn.tar", bytes)?;
//
// Ok(())
// }