2019-01-23 04:04:03 +04:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io::BufReader;
|
2019-01-27 03:31:37 +04:00
|
|
|
use std::path::Path;
|
2019-01-23 04:04:03 +04:00
|
|
|
|
2019-01-26 20:19:06 +04:00
|
|
|
extern crate clap;
|
|
|
|
use clap::{load_yaml, App};
|
|
|
|
|
2019-01-27 03:56:51 +04:00
|
|
|
extern crate rustc_serialize;
|
|
|
|
use rustc_serialize::json;
|
|
|
|
|
2019-01-26 19:37:16 +04:00
|
|
|
mod parser;
|
|
|
|
use parser::*;
|
2019-01-23 04:04:03 +04:00
|
|
|
|
2019-01-23 02:04:00 +04:00
|
|
|
fn main() {
|
2019-01-26 20:19:06 +04:00
|
|
|
let yaml = load_yaml!("cli/ru.yml");
|
|
|
|
let matches = App::from_yaml(yaml).get_matches();
|
|
|
|
|
|
|
|
let path = matches.value_of("FILE").unwrap();
|
|
|
|
|
2019-01-27 03:31:37 +04:00
|
|
|
match Path::new(path).exists() {
|
|
|
|
true => {
|
|
|
|
let file: File = File::open(path).unwrap();
|
|
|
|
let data: ParserResult = parse(BufReader::new(file));
|
2019-01-27 03:56:51 +04:00
|
|
|
println!("{}", json::as_pretty_json(&data));
|
2019-01-27 03:31:37 +04:00
|
|
|
}
|
|
|
|
_ => panic!("Error File!"),
|
|
|
|
};
|
2019-01-23 02:04:00 +04:00
|
|
|
}
|