mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-21 20:38:44 +00:00
Move asset clearing to assets module
This commit is contained in:
parent
b21fb6bca8
commit
2712d63a4b
@ -157,14 +157,24 @@ impl HighlightingAssets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn theme_set_path() -> PathBuf {
|
fn theme_set_path() -> PathBuf {
|
||||||
PROJECT_DIRS.cache_dir().join("themes.bin")
|
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")
|
PROJECT_DIRS.cache_dir().join("syntaxes.bin")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn config_dir() -> Cow<'static, str> {
|
pub fn config_dir() -> Cow<'static, str> {
|
||||||
PROJECT_DIRS.config_dir().to_string_lossy()
|
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");
|
||||||
|
}
|
||||||
|
11
src/main.rs
11
src/main.rs
@ -27,13 +27,12 @@ mod printer;
|
|||||||
mod style;
|
mod style;
|
||||||
mod terminal;
|
mod terminal;
|
||||||
|
|
||||||
use std::fs;
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
use app::App;
|
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};
|
use features::{list_languages, print_files};
|
||||||
|
|
||||||
mod errors {
|
mod errors {
|
||||||
@ -75,13 +74,7 @@ fn run() -> Result<bool> {
|
|||||||
let assets = HighlightingAssets::from_files(source_dir)?;
|
let assets = HighlightingAssets::from_files(source_dir)?;
|
||||||
assets.save(target_dir)?;
|
assets.save(target_dir)?;
|
||||||
} else if cache_matches.is_present("clear") {
|
} else if cache_matches.is_present("clear") {
|
||||||
print!("Clearing theme set cache ... ");
|
clear_assets();
|
||||||
fs::remove_file(theme_set_path()).ok();
|
|
||||||
println!("okay");
|
|
||||||
|
|
||||||
print!("Clearing syntax set cache ... ");
|
|
||||||
fs::remove_file(syntax_set_path()).ok();
|
|
||||||
println!("okay");
|
|
||||||
} else if cache_matches.is_present("config-dir") {
|
} else if cache_matches.is_present("config-dir") {
|
||||||
println!("{}", config_dir());
|
println!("{}", config_dir());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user