on master help sign in
Move asset clearing to assets module
commit2712d63a4bb2fe6dc46bbd5a6a2917ec4718bd6f authorEzinwa Okpoechi <brainmaestro@outlook.com> dateMon 21 May 2018, 22:29 (8 years ago) parentb21fb6b
2 files changed+14−11
src/assets.rs+12−2 src/main.rs+2−9
src/assets.rs+12−2
@@ -157,14 +157,24 @@ impl HighlightingAssets {
157157 }
158158}
159159
160−pub fn theme_set_path() -> PathBuf {
160+fn theme_set_path() -> PathBuf {
161161 PROJECT_DIRS.cache_dir().join("themes.bin")
162162}
163163
164−pub fn syntax_set_path() -> PathBuf {
164+fn syntax_set_path() -> PathBuf {
165165 PROJECT_DIRS.cache_dir().join("syntaxes.bin")
166166}
167167
168168pub fn config_dir() -> Cow<'static, str> {
169169 PROJECT_DIRS.config_dir().to_string_lossy()
170170}
171+
172+pub fn clear_assets() {
173+ print!("Clearing theme set cache ... ");
174+ fs::remove_file(theme_set_path()).ok();
175+ println!("okay");
176+
177+ print!("Clearing syntax set cache ... ");
178+ fs::remove_file(syntax_set_path()).ok();
179+ println!("okay");
180+}
src/main.rs+2−9
@@ -27,13 +27,12 @@ mod printer;
2727mod style;
2828mod terminal;
2929
30−use std::fs;
3130use std::io;
3231use std::path::Path;
3332use std::process;
3433
3534use app::App;
36−use assets::{config_dir, syntax_set_path, theme_set_path, HighlightingAssets};
35+use assets::{clear_assets, config_dir, HighlightingAssets};
3736use features::{list_languages, print_files};
3837
3938mod errors {
@@ -75,13 +74,7 @@ fn run() -> Result<bool> {
7574 let assets = HighlightingAssets::from_files(source_dir)?;
7675 assets.save(target_dir)?;
7776 } else if cache_matches.is_present("clear") {
78− print!("Clearing theme set cache ... ");
79− fs::remove_file(theme_set_path()).ok();
80− println!("okay");
81−
82− print!("Clearing syntax set cache ... ");
83− fs::remove_file(syntax_set_path()).ok();
84− println!("okay");
77+ clear_assets();
8578 } else if cache_matches.is_present("config-dir") {
8679 println!("{}", config_dir());
8780 }