2017-07-18 14:27:50 +01:00
|
|
|
#[macro_use]
|
|
|
|
extern crate clap;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
2017-07-17 09:52:22 +01:00
|
|
|
|
|
|
|
extern crate serde_yaml;
|
2017-08-14 21:45:23 +01:00
|
|
|
extern crate pandoc;
|
2017-08-27 21:16:40 +01:00
|
|
|
extern crate wkhtmltopdf;
|
2017-08-31 20:46:36 +01:00
|
|
|
extern crate sciter;
|
2017-09-09 23:28:18 +01:00
|
|
|
extern crate zip;
|
|
|
|
extern crate mktemp;
|
2017-12-21 18:50:55 +00:00
|
|
|
extern crate tera;
|
2017-12-21 20:13:51 +00:00
|
|
|
extern crate chrono;
|
2017-07-17 09:52:22 +01:00
|
|
|
|
2017-08-14 21:22:53 +01:00
|
|
|
use std::io::{self, Write};
|
|
|
|
use std::process::exit;
|
|
|
|
|
2017-07-12 14:01:52 +01:00
|
|
|
mod args;
|
2017-07-17 09:52:22 +01:00
|
|
|
mod config;
|
2017-07-20 09:14:48 +01:00
|
|
|
mod input;
|
2017-07-26 15:22:20 +01:00
|
|
|
mod utils;
|
2017-08-14 21:45:23 +01:00
|
|
|
mod build;
|
2017-08-27 23:42:56 +01:00
|
|
|
mod output;
|
2017-09-06 18:20:45 +01:00
|
|
|
mod processors;
|
|
|
|
mod html;
|
2017-09-06 21:40:48 +01:00
|
|
|
mod assets;
|
2017-12-21 18:50:55 +00:00
|
|
|
mod templating;
|
2017-07-12 14:01:52 +01:00
|
|
|
|
2017-07-12 14:40:25 +01:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests;
|
|
|
|
|
2017-08-14 21:22:53 +01:00
|
|
|
use clap::ArgMatches;
|
2017-09-06 18:20:45 +01:00
|
|
|
use input::read_input_files;
|
2017-08-14 21:22:53 +01:00
|
|
|
use config::Config;
|
2017-09-06 18:20:45 +01:00
|
|
|
use build::build_input;
|
|
|
|
use output::output;
|
|
|
|
use utils::ok_or_exit;
|
2017-08-14 21:22:53 +01:00
|
|
|
|
2017-09-06 18:20:45 +01:00
|
|
|
|
|
|
|
fn build(config: Config) -> Result<(), String> {
|
2017-11-21 22:12:46 +00:00
|
|
|
let input = try!(read_input_files(config.absolute_inputs()));
|
2017-09-06 18:20:45 +01:00
|
|
|
let raw_html = try!(build_input(config.clone(), input));
|
|
|
|
println!("{}", raw_html);
|
|
|
|
try!(output(config, raw_html));
|
|
|
|
return Ok(());
|
2017-08-14 21:22:53 +01:00
|
|
|
}
|
|
|
|
|
2017-08-14 22:10:05 +01:00
|
|
|
fn get_config(args: ArgMatches) -> Config {
|
2017-11-24 22:39:37 +00:00
|
|
|
let mut config = ok_or_exit(config::read::get_config());
|
2017-08-14 21:22:53 +01:00
|
|
|
config.verbosity = args::get_verbose(args);
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-01 21:10:25 +01:00
|
|
|
fn main() {
|
2017-07-17 10:02:58 +01:00
|
|
|
let args = args::get_matches();
|
2017-08-14 21:22:53 +01:00
|
|
|
let subcommand = args.subcommand_name().expect("subcommand error");
|
|
|
|
match subcommand {
|
|
|
|
"build" => {
|
2017-08-14 22:10:05 +01:00
|
|
|
let config = get_config(args.clone());
|
2017-09-10 19:23:12 +01:00
|
|
|
utils::ok_or_exit(build(config.clone()));
|
2017-08-14 21:22:53 +01:00
|
|
|
}
|
|
|
|
cmd => {
|
|
|
|
writeln!(io::stderr(), "Unknown command {}.", cmd).unwrap();
|
|
|
|
exit(1);
|
|
|
|
}
|
2017-07-17 10:02:58 +01:00
|
|
|
}
|
2017-07-01 21:10:25 +01:00
|
|
|
}
|