From b8fadf82a9cfb172300d8fbdb9ef144e6dc30152 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 2 Sep 2017 10:13:57 +0100 Subject: [PATCH] only render PDF if needed --- src/config/validate.rs | 3 +++ src/output/mod.rs | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/config/validate.rs b/src/config/validate.rs index 19f1f90..040224d 100644 --- a/src/config/validate.rs +++ b/src/config/validate.rs @@ -30,6 +30,9 @@ fn check_input_files(config: Value) -> ValidationResult { fn check_output_files(config: Value) -> ValidationResult { let files = read::get_output_files(config); let output_types = vec!["pdf".into()]; + if files.is_empty() { + return Err("You need to provide at least 1 output format".into()); + } for file_def in files.iter() { let dir = file_def.1.parent().unwrap(); if !dir.exists() || !dir.is_dir() { diff --git a/src/output/mod.rs b/src/output/mod.rs index cfa2640..cae7fe4 100644 --- a/src/output/mod.rs +++ b/src/output/mod.rs @@ -2,7 +2,9 @@ use config::Config; pub mod pdf; -pub fn output(config: Config, output: String) -> Result { - pdf::output(config, output); - return Ok("".into()); +pub fn output(config: Config, output: String) -> Result<(), String> { + if config.output.contains_key("pdf") { + try!(pdf::output(config, output)); + } + return Ok(()); }