2019-01-27 04:10:08 +04:00
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
|
|
|
extern crate serde_json;
|
|
|
|
|
|
|
|
extern crate clap;
|
|
|
|
extern crate xml;
|
|
|
|
|
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
|
|
|
use clap::{load_yaml, App};
|
|
|
|
|
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-27 04:22:59 +04:00
|
|
|
let yaml = load_yaml!("cli/en.yml");
|
2019-01-26 20:19:06 +04:00
|
|
|
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();
|
2019-01-27 04:08:26 +04:00
|
|
|
let data: ParserResult = parser(BufReader::new(file));
|
2019-01-27 04:43:55 +04:00
|
|
|
println!("{}", serde_json::to_string_pretty(&data).unwrap());
|
2019-01-27 03:31:37 +04:00
|
|
|
}
|
2019-01-27 04:43:55 +04:00
|
|
|
_ => panic!("File {:#?} does not exist or is not available.", path),
|
2019-01-27 03:31:37 +04:00
|
|
|
};
|
2019-01-23 02:04:00 +04:00
|
|
|
}
|