|
|
|
@ -1,8 +1,9 @@
|
|
|
|
|
use structopt::StructOpt;
|
|
|
|
|
use toml::Value;
|
|
|
|
|
|
|
|
|
|
use std::collections::hash_map::DefaultHasher;
|
|
|
|
|
use std::fs::{copy, create_dir, read_to_string};
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
use std::fs::{read_to_string, copy};
|
|
|
|
|
|
|
|
|
|
#[derive(StructOpt, Debug)]
|
|
|
|
|
/// structure representing command line arguments
|
|
|
|
@ -23,6 +24,9 @@ struct Opt {
|
|
|
|
|
template: PathBuf,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn replace(input: String, rules: &[(&str, &str)]) -> String {
|
|
|
|
|
unimplemented!();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
// parse command line arguments
|
|
|
|
@ -30,10 +34,24 @@ fn main() {
|
|
|
|
|
//println!("{:?}", opt);
|
|
|
|
|
|
|
|
|
|
// parse toml
|
|
|
|
|
let value = read_to_string(opt.toml)
|
|
|
|
|
.unwrap()
|
|
|
|
|
.parse::<Value>()
|
|
|
|
|
.unwrap();
|
|
|
|
|
println!("{:?}", value);
|
|
|
|
|
|
|
|
|
|
let value = read_to_string(&opt.toml).unwrap().parse::<Value>().unwrap();
|
|
|
|
|
println!("{:#?}", value);
|
|
|
|
|
|
|
|
|
|
// create output directory
|
|
|
|
|
// if it doesn't exist
|
|
|
|
|
if (!opt.output.exists()) {
|
|
|
|
|
create_dir(&opt.output).unwrap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// read template
|
|
|
|
|
let input = read_to_string(
|
|
|
|
|
&[opt.output, PathBuf::from("front.html")]
|
|
|
|
|
.iter()
|
|
|
|
|
.collect::<PathBuf>(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// create rules
|
|
|
|
|
let page = value.get("page").unwrap().as_array().unwrap();
|
|
|
|
|
|
|
|
|
|
println!("{:#?}", page);
|
|
|
|
|
}
|
|
|
|
|