mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 03:55:28 +00:00
main: Make ouch return 1 upon failure
This commit is contained in:
parent
c14874072d
commit
ceb507fd14
37
src/main.rs
37
src/main.rs
@ -11,37 +11,22 @@ mod utils;
|
|||||||
mod compressors;
|
mod compressors;
|
||||||
mod decompressors;
|
mod decompressors;
|
||||||
|
|
||||||
|
use evaluator::Evaluator;
|
||||||
|
|
||||||
fn main() -> error::OuchResult<()> {
|
fn main() -> error::OuchResult<()> {
|
||||||
let print_error = |err| {
|
let print_error = |err| {
|
||||||
println!("{}", err);
|
println!("{}", err);
|
||||||
|
err
|
||||||
};
|
};
|
||||||
|
|
||||||
let matches = cli::get_matches();
|
let matches = cli::get_matches();
|
||||||
cli::Command::try_from(matches)
|
let command = match cli::Command::try_from(matches) {
|
||||||
.map(|command| evaluator::Evaluator::evaluate(command).unwrap_or_else(print_error))
|
Ok(command) => command,
|
||||||
.unwrap_or_else(print_error);
|
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(())
|
|
||||||
// }
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user