only render PDF if needed

This commit is contained in:
Jake Howard 2017-09-02 10:13:57 +01:00
parent a0f945947a
commit b8fadf82a9
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 8 additions and 3 deletions

View file

@ -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() {

View file

@ -2,7 +2,9 @@ use config::Config;
pub mod pdf;
pub fn output(config: Config, output: String) -> Result<String, String> {
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(());
}