minigrep.rs/src/main.rs

23 lines
561 B
Rust
Raw Permalink Normal View History

2018-09-18 05:33:56 +00:00
extern crate grep;
use std::env;
2018-09-18 06:24:00 +00:00
use std::process;
2018-09-18 05:33:56 +00:00
2018-09-18 04:05:47 +00:00
fn main() {
2018-09-18 05:33:56 +00:00
let args: Vec<String> = env::args().collect();
2018-09-18 06:25:58 +00:00
let conf = grep::Config::new(&args).unwrap_or_else(|err| {
2018-09-19 04:23:18 +00:00
eprintln!("Problem parsing arguments: {}", err);
2018-09-18 06:24:00 +00:00
process::exit(1);
});
//let filename = &conf.filename.clone();
2018-09-18 05:33:56 +00:00
2018-09-18 06:25:58 +00:00
if let Err(e) = grep::run(conf) {
2018-09-19 04:23:18 +00:00
eprintln!("Big bad bada boom!\n{:?}", e);
2018-09-18 06:24:00 +00:00
//println!("Big bad bada boom!\n{:?}", e.kind());
//println!("Big bad bada boom!\n{}", e.description());
process::exit(1);
}
}