Update README, slightly reduce code repetition
[ouch.git] / src / main.rs
bloba00387cea9a5f01220f8a5a4e7d04498dfba60e0
1 use std::convert::TryFrom;
3 use colored::Colorize;
5 mod cli;
6 mod error;
7 mod extension;
8 mod file;
9 mod test;
10 mod evaluator;
11 mod utils;
13 mod compressors;
14 mod decompressors;
16 fn main() -> error::OuchResult<()>{
17     let print_error = |err| {
18         println!("{}: {}", "error".red(), err);
19     };
20     let matches = cli::get_matches();
21     match cli::Command::try_from(matches) {
22         Ok(command) => {
23             match evaluator::Evaluator::evaluate(command) {
24                 Ok(_) => {},
25                 Err(err) => print_error(err)
26             }
27         }
28         Err(err) => {
29             print_error(err)
30         }
31     }
33     Ok(())
36 // fn main() -> error::OuchResult<()> {
38 //     use tar::{Builder};
39 //     use walkdir::WalkDir;
41 //     let mut b = Builder::new(Vec::new());
42     
43 //     for entry in WalkDir::new("src") {
44 //         let entry = entry?;
45 //         let mut file = std::fs::File::open(entry.path())?;
46 //         b.append_file(entry.path(), &mut file)?;
47 //     }
49 //     // let mut file = std::fs::File::open("Cargo.toml")?;
50 //     // b.append_file("Cargo.toml", &mut file)?;
52 //     let bytes = b.into_inner()?;
54 //     std::fs::write("daaaaamn.tar", bytes)?;
56 //     Ok(())
57 // }