From 2712d63a4bb2fe6dc46bbd5a6a2917ec4718bd6f Mon Sep 17 00:00:00 2001 From: Ezinwa Okpoechi Date: Mon, 21 May 2018 22:29:03 +0200 Subject: [PATCH] Move asset clearing to assets module --- src/assets.rs | 14 ++++++++++++-- src/main.rs | 11 ++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/assets.rs b/src/assets.rs index 91139d38..2e4b122c 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -157,14 +157,24 @@ impl HighlightingAssets { } } -pub fn theme_set_path() -> PathBuf { +fn theme_set_path() -> PathBuf { PROJECT_DIRS.cache_dir().join("themes.bin") } -pub fn syntax_set_path() -> PathBuf { +fn syntax_set_path() -> PathBuf { PROJECT_DIRS.cache_dir().join("syntaxes.bin") } pub fn config_dir() -> Cow<'static, str> { PROJECT_DIRS.config_dir().to_string_lossy() } + +pub fn clear_assets() { + print!("Clearing theme set cache ... "); + fs::remove_file(theme_set_path()).ok(); + println!("okay"); + + print!("Clearing syntax set cache ... "); + fs::remove_file(syntax_set_path()).ok(); + println!("okay"); +} diff --git a/src/main.rs b/src/main.rs index 3b910220..d375441b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,13 +27,12 @@ mod printer; mod style; mod terminal; -use std::fs; use std::io; use std::path::Path; use std::process; use app::App; -use assets::{config_dir, syntax_set_path, theme_set_path, HighlightingAssets}; +use assets::{clear_assets, config_dir, HighlightingAssets}; use features::{list_languages, print_files}; mod errors { @@ -75,13 +74,7 @@ fn run() -> Result { let assets = HighlightingAssets::from_files(source_dir)?; assets.save(target_dir)?; } else if cache_matches.is_present("clear") { - print!("Clearing theme set cache ... "); - fs::remove_file(theme_set_path()).ok(); - println!("okay"); - - print!("Clearing syntax set cache ... "); - fs::remove_file(syntax_set_path()).ok(); - println!("okay"); + clear_assets(); } else if cache_matches.is_present("config-dir") { println!("{}", config_dir()); }