Set default format to html

pull/1/head
trivernis 5 years ago
parent 72010bebb8
commit 4090ce6814

@ -2,6 +2,7 @@ use snekdown::format::html::ToHtml;
use snekdown::parser::Parser;
use std::fs::write;
use std::time::Instant;
use termion::style;
use std::path::PathBuf;
use structopt::StructOpt;
@ -12,7 +13,7 @@ struct Opt {
input: PathBuf,
#[structopt(parse(from_os_str))]
output: PathBuf,
#[structopt(short, long)]
#[structopt(short, long, default_value = "html")]
format: String,
}
@ -21,9 +22,12 @@ fn main() {
let start = Instant::now();
let mut parser = Parser::new_from_file(opt.input.to_str().unwrap().to_string()).unwrap();
let document = parser.parse();
println!("Total duration: {:?}", start.elapsed());
println!("{}Parsing took: {:?}", style::Italic, start.elapsed());
let start_render = Instant::now();
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)
}

Loading…
Cancel
Save