You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
snekdown/src/main.rs

34 lines
1.0 KiB
Rust

use snekdown::format::html::ToHtml;
use snekdown::parser::Parser;
4 years ago
use std::fs::write;
use std::time::Instant;
use termion::style;
4 years ago
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
struct Opt {
#[structopt(parse(from_os_str))]
input: PathBuf,
#[structopt(parse(from_os_str))]
output: PathBuf,
#[structopt(short, long, default_value = "html")]
4 years ago
format: String,
}
fn main() {
4 years ago
let opt: Opt = Opt::from_args();
let start = Instant::now();
4 years ago
let mut parser = Parser::new_from_file(opt.input.to_str().unwrap().to_string()).unwrap();
let document = parser.parse();
println!("{}Parsing took: {:?}", style::Italic, start.elapsed());
let start_render = Instant::now();
4 years ago
match opt.format.as_str() {
"html" => write(opt.output.to_str().unwrap(), document.to_html()).unwrap(),
_ => println!("Unknown format {}", opt.format),
}
println!("Rendering took: {:?}", start_render.elapsed());
println!("Total: {:?}{}", start.elapsed(), style::Reset)
}