Cleanup csl file on program close

This commit is contained in:
Jake Howard 2017-09-10 19:23:12 +01:00
parent 0e03bc0740
commit c3e13888d0
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 10 additions and 1 deletions

View file

@ -3,6 +3,7 @@ use serde_yaml::Value;
use std::path::PathBuf;
use std::collections::HashMap;
use utils::result_prefix;
use std::fs::remove_file;
pub mod read;
pub mod validate;
@ -45,3 +46,10 @@ pub fn get_config() -> Result<Config, String> {
try!(result_prefix(validate::validate(config.clone()), "Config Validation Error".into()));
return Ok(Config::new(config));
}
pub fn cleanup_config(config: Config) {
if config.references.is_some() {
remove_file(config.references.unwrap().csl).expect("Failed to remove file");
}
}

View file

@ -56,7 +56,8 @@ fn main() {
match subcommand {
"build" => {
let config = get_config(args.clone());
utils::ok_or_exit(build(config));
utils::ok_or_exit(build(config.clone()));
config::cleanup_config(config);
}
cmd => {
writeln!(io::stderr(), "Unknown command {}.", cmd).unwrap();