aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: dbf0f2896d76d1870cf2891c4dd5ac689ae42234 (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),
    };
}