aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 6135a155c154df8db89432a0ed2f23eaf3a7854f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#[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),
	};
}