bbb2json/src/main.rs
Valentin Popov b5e0b43447
Sun, 27 Jan 2019 04:43:55 +0400
Signed-off-by: Valentin Popov <info@valentineus.link>
2019-01-27 04:43:55 +04:00

32 lines
673 B
Rust

#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate clap;
extern crate xml;
use std::fs::File;
use std::io::BufReader;
use std::path::Path;
use clap::{load_yaml, App};
mod parser;
use parser::*;
fn main() {
let yaml = load_yaml!("cli/en.yml");
let matches = App::from_yaml(yaml).get_matches();
let path = matches.value_of("FILE").unwrap();
match Path::new(path).exists() {
true => {
let file: File = File::open(path).unwrap();
let data: ParserResult = parser(BufReader::new(file));
println!("{}", serde_json::to_string_pretty(&data).unwrap());
}
_ => panic!("File {:#?} does not exist or is not available.", path),
};
}