use std::process;
use clap::{App, Arg};
use hatchling::convert_facebook_to_solid;
use std::fs::File;
use std::io::prelude::*;
fn main() {
let matches = App::new("hatchling")
.version("0.1")
.about("A tool to convert Facebook data to Linked Data")
.author("Sean McBride")
.arg(
Arg::with_name("input")
.help("Path to the Facebook profile_information.json file")
.required(true)
.index(1),
)
.arg(
Arg::with_name("output")
.help("Path for the resuling Turtle file")
.required(true)
.index(2),
)
.arg(
Arg::with_name("friends")
.short("f")
.long("friends")
.help("Path to an optional friends file generated by the instructions at https://github.com/bushidocodes/hatchling")
.takes_value(true),
)
.get_matches();
let input = matches.value_of("input").unwrap();
let output = matches.value_of("output").unwrap();
let friends = matches.value_of("friends");
let solid_profile = convert_facebook_to_solid(input, friends).unwrap_or_else(|err| {
eprintln!("{}", err);
process::exit(1)
});
let mut file = File::create(output).unwrap();
file.write_all(solid_profile.as_bytes()).unwrap();
}