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

30 lines
816 B
Rust

use snekdown::format::html::ToHtml;
use snekdown::parser::Parser;
4 years ago
use std::fs::write;
use std::time::Instant;
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)]
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!("Total duration: {:?}", start.elapsed());
4 years ago
match opt.format.as_str() {
"html" => write(opt.output.to_str().unwrap(), document.to_html()).unwrap(),
_ => println!("Unknown format {}", opt.format),
}
}