From 4090ce68141e27a3c9f1f7add24bc9bf3a855f0c Mon Sep 17 00:00:00 2001 From: trivernis Date: Sat, 30 May 2020 19:17:33 +0200 Subject: [PATCH] Set default format to html --- src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index e4a9afd..4852b5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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) }